tinybench - v6.1.1
    Preparing search index...

    Function calibrateTimerOverhead

    • Estimates the cost of a single provider.fn() call by repeatedly measuring back-to-back pairs and reducing the strictly-positive deltas to a single value via the chosen estimator.

      Coarse-timer detection. When the timer resolution R exceeds the call cost C (C < R / 2), the probability that any pair crosses a tick boundary is C / R < 1 / 2, so most pairs return a delta of zero. The positive deltas that do occur each equal exactly one tick R, not the call cost. To prevent catastrophic over-correction, the function returns 0 whenever fewer than half of the pairs produce a positive delta.

      Bigint precision. The subtraction is performed in the provider's native type before conversion to milliseconds (toMs(b - a)). For hrtimeNow, this preserves precision when absolute timestamps exceed Number.MAX_SAFE_INTEGER ns (≈ 104 days uptime).

      JIT warmup. A discarded warmup phase ensures fn and toMs are JIT-compiled to their steady-state tier before measurements begin.

      Parameters

      Returns number

      the estimated overhead in milliseconds, never negative; 0 when the timer resolution dominates or no positive delta is observed