# `Controls.Rate`
[🔗](https://github.com/harmont-dev/hyper/blob/main/lib/controls/rate.ex#L1)

Turns a monotonically increasing byte counter (e.g. `/proc/diskstats` sectors
or `/proc/net/dev` bytes) into a per-second rate.

The first observation has no baseline, and a reboot resets the counter
backwards; both cases return `:skip` (carrying the new baseline) rather than a
meaningless or negative rate. `mono_ms` must come from `System.monotonic_time/1`.

# `state`

```elixir
@type state() :: {non_neg_integer(), integer()} | nil
```

# `compute`

```elixir
@spec compute(state(), non_neg_integer(), integer()) ::
  {:ok, float(), state()} | {:skip, state()}
```

Given the previous `state`, the latest cumulative `count`, and the monotonic
timestamp `mono_ms` of this reading, return the rate in counter-units per
second together with the new state.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
