Class | Logging::Stats::Sampler |
In: |
lib/logging/stats.rb
|
Parent: | Object |
A very simple little class for doing some basic fast statistics sampling. You feed it either samples of numeric data you want measured or you call Sampler#tick to get it to add a time delta between the last time you called it. When you‘re done either call sum, sumsq, num, min, max, mean or sd to get the information. The other option is to just call to_s and see everything.
It does all of this very fast and doesn‘t take up any memory since the samples are not stored but instead all the values are calculated on the fly.
last | [R] | |
max | [R] | |
min | [R] | |
name | [R] | |
num | [R] | |
sum | [R] | |
sumsq | [R] |
Class method that returns the headers that a CSV file would have for the values that this stats object is using.
Coalesce the statistics from the other sampler into this one. The other sampler is not modified by this method.
Coalescing the same two samplers multiple times should only be done if one of the samplers is reset between calls to this method. Otherwise statistics will be counted multiple times.
You can just call tick repeatedly if you need the delta times between a set of sample periods, but many times you actually want to sample how long something takes between a start/end period. Call mark at the beginning and then tick at the end you‘ll get this kind of measurement. Don‘t mix mark/tick and tick sampling together or the measurement will be meaningless.