C++ Metrics is a header-only library to measure parameter distributions in an embedded application. The library is inspired by Coda Hale's Metrics library, but has fewer features.
Class | Description |
---|---|
Gauge | Store a single measurement |
MinMax | Store minimum/maximum measurement |
MinMeanMax | Same as above + mean value |
Variance | Same as above + (sample) variance, (sample) standard deviation, and RMS |
Kurtosis | Same as above + skew and kurtosis |
LinearRegression | Least squares linear regression - best fit line through measurements |
Histogram | Store n samples in a reservoir, get bins, min/Q25/Q50/Q75/max |
Class | Description |
---|---|
SlidingWindowReservoir | Store last n measurements |
SamplingReservoir | Store n randomly selected measurements from all measurements |
- low overhead: typically < 10 ns / measurement
- updating is made thread-safe by using mutexes, mutexes can be disabled at compile time
- optional registry for reporting all metrics at once
- no build system needed, just copy the header files in a project
- no background threads
- no external dependencies
- uses naive locking (mutex) when sampling - can impact performance on some processors or when parallellism is very high
- no rate-type measurements
- Reservoir sampling: optimal algorithm L
- Variance: Welford's online algorithm
- Linear regression using LSQ: Simple linear regression
- John D. Cook - Computing skewness and kurtosis in one pass - online calculation of mean/variance/skew/kurtosis in C++ - inspired me to also implement += and + on statistics