module Cryload::Histogram

Overview

HDR-style logarithmic histogram: ~1% relative precision from 1µs to 1h in a few thousand buckets instead of a dense linear array.

Two representations share the same bucket layout so they can be merged without conversion: Sparse is worker-local and lock-free, Dense is the global aggregate merged under the Stats mutex.

Defined in:

cryload/histogram.cr

Constant Summary

BUCKET_COUNT = ((Math.log(MAX_MS / MIN_MS)) / LOG_GROWTH).ceil.to_i + 1
GROWTH = 1.01
LOG_GROWTH = Math.log(GROWTH)
MAX_MS = 3600000.0
MIN_MS = 0.001

Class Method Summary

Class Method Detail

def self.bucket_index(value_ms : Float64) : Int32 #

def self.bucket_value(index : Int32) : Float64 #

Geometric midpoint of the bucket, the best estimate for values in it.