|
Lightweight 0.20260921.0
|
#include <SqlStatistics.hpp>
Public Member Functions | |
| LIGHTWEIGHT_API double | AverageMicroseconds () const noexcept |
| LIGHTWEIGHT_API std::uint64_t | PercentileMicroseconds (double percentile) const noexcept |
Static Public Member Functions | |
| static constexpr std::size_t | BucketOf (std::uint64_t microseconds) noexcept |
Public Attributes | |
| std::array< std::uint64_t, BucketCount > | buckets {} |
Per-bucket sample counts; bucket i covers [2^(i-1), 2^i) microseconds. | |
| std::uint64_t | count {} |
| Total number of samples recorded. | |
| std::uint64_t | totalMicroseconds {} |
| Sum of all sample values, in microseconds. | |
| std::uint64_t | minMicroseconds {} |
| Smallest sample recorded, in microseconds; 0 when count is 0. | |
| std::uint64_t | maxMicroseconds {} |
| Largest sample recorded, in microseconds; 0 when count is 0. | |
Static Public Attributes | |
| static constexpr std::size_t | BucketCount = 32 |
| Number of histogram buckets. | |
A fixed-bucket latency histogram, in microseconds.
Buckets are power-of-two spaced: bucket i counts samples in [2^(i-1), 2^i) microseconds, with bucket 0 counting [0, 1) and the last bucket acting as an open-ended overflow. That covers sub-microsecond calls up to ~35 minutes in BucketCount buckets, and makes bucket selection a single std::bit_width rather than a search — cheap enough to sit on the hot path.
This is the plain-struct snapshot type. It is a value: copy it, export it, diff two of them. The live counters are held separately by SqlStatistics.
Definition at line 83 of file SqlStatistics.hpp.
|
noexcept |
Retrieves the arithmetic mean sample value.
|
noexcept |
Estimates a percentile from the bucket counts.
The result is the upper bound of the bucket the percentile falls into, so it is an over-estimate bounded by a factor of two — the standard trade-off for a power-of-two histogram, and accurate enough to spot a regression without storing every sample.
| percentile | The percentile to estimate, in [0.0, 1.0] (e.g. 0.99 for p99). |
|
inlinestaticconstexprnoexcept |
Retrieves the index of the bucket a given sample value falls into.
| microseconds | The sample value. |
BucketCount - 1. Definition at line 123 of file SqlStatistics.hpp.
References BucketCount.
|
staticconstexpr |
Number of histogram buckets.
Definition at line 86 of file SqlStatistics.hpp.
Referenced by BucketOf().
| std::array<std::uint64_t, BucketCount> Lightweight::SqlLatencyHistogram::buckets {} |
Per-bucket sample counts; bucket i covers [2^(i-1), 2^i) microseconds.
Definition at line 89 of file SqlStatistics.hpp.
| std::uint64_t Lightweight::SqlLatencyHistogram::count {} |
Total number of samples recorded.
Definition at line 92 of file SqlStatistics.hpp.
| std::uint64_t Lightweight::SqlLatencyHistogram::totalMicroseconds {} |
Sum of all sample values, in microseconds.
Definition at line 95 of file SqlStatistics.hpp.
| std::uint64_t Lightweight::SqlLatencyHistogram::minMicroseconds {} |
Smallest sample recorded, in microseconds; 0 when count is 0.
Definition at line 98 of file SqlStatistics.hpp.
| std::uint64_t Lightweight::SqlLatencyHistogram::maxMicroseconds {} |
Largest sample recorded, in microseconds; 0 when count is 0.
Definition at line 101 of file SqlStatistics.hpp.