A ProfileSampler is a sampler of profile times. It aggregates up profile events that happen for the same source. It is based upon the RFuzz::Sampler class from the rfuzz gem
return the mean of the data
# File lib/amalgalite/profile_tap.rb, line 50 def mean @sum / @n end
reset the internal state so it may be used again
# File lib/amalgalite/profile_tap.rb, line 24 def reset! @sum = 0.0 @sumsq = 0.0 @n = 0 @min = 0.0 @max = 0.0 end
add a sample to the calculations
# File lib/amalgalite/profile_tap.rb, line 35 def sample( value ) @sum += value @sumsq += (value * value) if @n == 0 then @min = @max = value else @min = value if value < @min @max = value if value > @max end @n += 1 end
returns the standard deviation of the data
# File lib/amalgalite/profile_tap.rb, line 57 def stddev begin return 0.0 if ( 1 == @n ) Math.sqrt( (@sumsq - ( @sum * @sum / @n)) / (@n-1) ) rescue Errno::EDOM return 0.0 end end
return all the values as an array
# File lib/amalgalite/profile_tap.rb, line 69 def to_a [ @name, @sum, @sumsq, @n, mean, stddev, @min, @max ] end
Generated with the Darkfish Rdoc Generator 2.