Up

Module Cpu_usage

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.

Signature

module Sampler : sig .. end

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 .. end

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.