class Hitimes::MutexedStats

The Stats class encapulsates capturing and reporting statistics. It is modeled after the RFuzz::Sampler class, but implemented in C. For general use you allocate a new Stats object, and then update it with new values. The Stats object will keep track of the min, max, count, sum and sumsq and when you want you may also retrieve the mean, stddev and rate.

this contrived example shows getting a list of all the files in a directory and running stats on file sizes.

s = Hitimes::Stats.new
dir = ARGV.shift || Dir.pwd
Dir.entries( dir ).each do |entry|
  fs = File.stat( entry )
  if fs.file? then
    s.update( fs.size )
   end
end

%w[ count min max mean sum stddev rate ].each do |m|
  puts "#{m.rjust(6)} : #{s.send( m ) }"
end