2006-03-26 15:01:50 -05:00
|
|
|
require 'test/unit'
|
|
|
|
require 'mongrel/stats'
|
|
|
|
|
|
|
|
class StatsTest < Test::Unit::TestCase
|
|
|
|
|
|
|
|
def test_sampling_speed
|
2006-04-01 04:09:10 -05:00
|
|
|
out = StringIO.new
|
|
|
|
|
2006-03-26 15:01:50 -05:00
|
|
|
s = Stats.new("test")
|
|
|
|
t = Stats.new("time")
|
|
|
|
|
|
|
|
10000.times { s.sample(rand(20)); t.tick }
|
|
|
|
|
2006-04-01 04:09:10 -05:00
|
|
|
s.dump("FIRST", out)
|
|
|
|
t.dump("FIRST", out)
|
2006-03-26 15:01:50 -05:00
|
|
|
|
|
|
|
old_mean = s.mean
|
|
|
|
old_sd = s.sd
|
|
|
|
|
|
|
|
s.reset
|
|
|
|
t.reset
|
|
|
|
10000.times { s.sample(rand(20)); t.tick }
|
|
|
|
|
2006-04-01 04:09:10 -05:00
|
|
|
s.dump("SECOND", out)
|
|
|
|
t.dump("SECOND", out)
|
2006-03-26 15:01:50 -05:00
|
|
|
assert_not_equal old_mean, s.mean
|
|
|
|
assert_not_equal old_mean, s.sd
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|