High Dynamic Range Histogram crystal implementation
A Histogram that supports recording and analyzing sampled data value counts across a configurable integer value range with configurable value precision within the range.
HdrHistogram is designed for recording histograms in latency and performance sensitive applications. The memory footprint is constant (depending only on precision), as is the work required to record a value.
Implementation heavily inspired HdrHistogram by Gil Tene and the different implementations that can be found on the project site. All errors are original content and not present in the original.
Supports:
- Recording values.
- Recording values with correction for coordinated omission.
- Get value at percentile.
- Get total count.
- Get min, max, mean and std deviation.
Add this to your application's shard.yml
:
dependencies:
hdrhistogram:
github: yxhuvud/hdrhistogram
First create a histogram with minimum, maximu and the amount of significant figures:
require "hdr_histogram"
histogram = HDRHistogram.new(1, 60 * 1000, 2)
Then it is possible to record values like:
histogram.record_value latency
It is also possible to record values with an expected known interval:
time_between_iteration = 100
histogram.record_corrected_value latency, time_between_iteration
It is possible to query a histogram for properties:
count = histogram.total_count
value = histogram.value_at_percentile(99.9)
It is possible to iterate over the values:
histogram.each_value do |i|
puts "value: #{i.value_from_index}, count: #{i.count_at_index}"
end
Fixme: Add benchmarks.
- Fork it ( https://github.com/yxhuvud/hdrhistogram/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- yxhuvud Linus Sellberg - creator, maintainer