Up

module Cpu_usage

: sig

Simple cpu usage statistics.

Samples are calculated as du/dt once a second where:

      du = Used user + system time since last sample
      dt = elapsed "wall clock" time since last sample

That is, each sample is the average cpu usage of the program over the last second.

#
module Sampler : sig
#
type t
#
val create : unit -> t
#
val take_sample : t -> Core.Std.Percent.t

Measure the percent of CPU used by this process since the last take_sample t call (or since t was created).

end
#
val samples : unit -> Core.Std.Percent.t Import.Pipe.Reader.t

Returns a pipe of samples as described above, one per second.

Pushback is not honored on the pipe and the pipe will grow unbounded in memory if it is not read from.

#
module Summary : sig
#
type t = {
# min
: Core.Std.Percent.t;
# max
: Core.Std.Percent.t;
# avg
: Core.Std.Percent.t;
}
#
val t_of_sexp : Sexplib.Sexp.t -> t
#
val sexp_of_t : t -> Sexplib.Sexp.t
#
val bin_t : t Core.Std.Bin_prot.Type_class.t
#
val bin_read_t : t Core.Std.Bin_prot.Read.reader
#
val __bin_read_t__ : (int -> t) Core.Std.Bin_prot.Read.reader
#
val bin_reader_t : t Core.Std.Bin_prot.Type_class.reader
#
val bin_size_t : t Core.Std.Bin_prot.Size.sizer
#
val bin_write_t : t Core.Std.Bin_prot.Write.writer
#
val bin_writer_t : t Core.Std.Bin_prot.Type_class.writer
end
#
val summaries : windows:Core.Std.Time.Span.t list -> (Core.Std.Time.Span.t * Summary.t) Import.Pipe.Reader.t

Get summarized cpu usage. Each window is the duration over which the summary should be calculated. The underlying data structure adapts to keep a sufficiently large history of samples to calculate summaries for all windows. The pipe will deliver one update per window per second. Window durations are rounded up to the nearest second.

Pushback is not honored on the pipe and the pipe will grow unbounded in memory if it is not read from.

end