Void Sentry
An AI-driven, real-time Sentry Turret platform leveraging asynchronous I/O and computer vision to deliver high-precision autonomous motion tracking on resource-constrained embedded hardware.
Loading...
Searching...
No Matches
windowed_counter.h File Reference

Per-window deltas of monotonically increasing counters, and the averages/percentages built on them (pure). More...

#include <cstdint>
#include <type_traits>

Go to the source code of this file.

Classes

class  stats::WindowedCounter< T >
 Remembers the previous reading of a free-running unsigned counter; sample() returns the delta since. More...
 

Functions

template<typename T >
constexpr T stats::window_avg (T sum, T count)
 sum / count, or 0 when count is 0 (an empty window).
 
constexpr unsigned stats::window_percent (uint64_t part, uint64_t whole)
 100 * part / whole as an integer percent, or 0 when whole is 0 (an empty window).
 

Detailed Description

Per-window deltas of monotonically increasing counters, and the averages/percentages built on them (pure).

The periodic stats line reports what happened in the last window (about 5 s), not since boot, because since-boot averages hid slowdowns. Each reported quantity is a free-running unsigned counter (frames, bytes, microseconds); WindowedCounter remembers the previous reading and returns the difference. Unsigned subtraction stays correct across a counter wrap, as long as the counter moves less than its range per window.