ESPectre SDK 2.8.0-280-gac7af68
Wi-Fi CSI motion sensing for ESP32 firmware
Loading...
Searching...
No Matches
espectre::RuntimeDiagnosticsSampler Class Reference

Converts cumulative diagnostics into rates over the interval between reads. More...

#include <runtime_diagnostics.h>

Public Member Functions

void reset (const RuntimeDiagnosticsSnapshot &snapshot, uint32_t now_ms)
 Establish the baseline the next sample() measures against.
RuntimeDiagnosticsSample sample (const RuntimeDiagnosticsSnapshot &snapshot, uint32_t now_ms)
 Derive rates since the previous read and adopt this one as the baseline.

Detailed Description

Converts cumulative diagnostics into rates over the interval between reads.

Call reset() when the owning frontend starts. Counter resets are treated as a new epoch, so rearming a traffic source cannot underflow a rate.

// once, at frontend startup:
sampler.reset(controller.diagnostics(), now_ms);
// whenever the owning frontend already produces a sensing update:
latest = sampler.sample(controller.diagnostics(), now_ms);
Threading
Not synchronized, and it holds the previous read. Sample it from the task that owns the runtime.

Definition at line 75 of file runtime_diagnostics.h.

Member Function Documentation

◆ reset()

void espectre::RuntimeDiagnosticsSampler::reset ( const RuntimeDiagnosticsSnapshot & snapshot,
uint32_t now_ms )

Establish the baseline the next sample() measures against.

Parameters
snapshotCurrent cumulative counters.
now_msMonotonic frontend clock, in milliseconds.

◆ sample()

RuntimeDiagnosticsSample espectre::RuntimeDiagnosticsSampler::sample ( const RuntimeDiagnosticsSnapshot & snapshot,
uint32_t now_ms )

Derive rates since the previous read and adopt this one as the baseline.

The caller owns the window. Shipped frontends invoke this from their existing periodic sensing update, so diagnostics do not add a timer.

Parameters
snapshotCurrent cumulative counters.
now_msMonotonic frontend clock, in milliseconds.
Returns
Rates over the elapsed interval. The link fields are always carried through; the rates are zero when there is no baseline yet or no time has elapsed.

The documentation for this class was generated from the following file: