Estimates the effective timer resolution from a latency sample set.
The estimator returns the smallest strictly positive sample value that
appears at least twice (the smallest reproducibly observed increment).
Requiring two occurrences gives a 2/n breakdown point and avoids being
pulled to an artificially low value by a single anomalous sample (cold
cache, GC pause, hardware quirk).
When no positive value appears more than once (e.g. a continuous
sub-microsecond timer with all unique samples), falls back to the strict
minimum of the positive values, which is the best available lower bound
in that case.
Exploits the sorted-ascending invariant: equal values are contiguous, so
the first strictly-positive value with an equal successor is the smallest
reproduced value, and the first strictly-positive value is the fallback
minimum. Runs in O(1) extra space with an early exit.
Estimates the effective timer resolution from a latency sample set.
The estimator returns the smallest strictly positive sample value that appears at least twice (the smallest reproducibly observed increment). Requiring two occurrences gives a 2/n breakdown point and avoids being pulled to an artificially low value by a single anomalous sample (cold cache, GC pause, hardware quirk).
When no positive value appears more than once (e.g. a continuous sub-microsecond timer with all unique samples), falls back to the strict minimum of the positive values, which is the best available lower bound in that case.
Exploits the sorted-ascending invariant: equal values are contiguous, so the first strictly-positive value with an equal successor is the smallest reproduced value, and the first strictly-positive value is the fallback minimum. Runs in O(1) extra space with an early exit.