2006-06-30 16:42:12 -04:00
|
|
|
# Copyright (c) 2005 Zed A. Shaw
|
|
|
|
# You can redistribute it and/or modify it under the same terms as Ruby.
|
|
|
|
#
|
|
|
|
# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
|
|
|
|
# for more information.
|
2006-05-21 10:46:42 -04:00
|
|
|
|
2006-03-26 15:01:50 -05:00
|
|
|
require 'test/unit'
|
|
|
|
require 'mongrel/stats'
|
2006-05-20 14:06:20 -04:00
|
|
|
require 'stringio'
|
2006-03-26 15:01:50 -05:00
|
|
|
|
|
|
|
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")
|
|
|
|
|
2006-06-05 05:30:36 -04:00
|
|
|
100.times { s.sample(rand(20)); t.tick }
|
2006-03-26 15:01:50 -05:00
|
|
|
|
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
|
2006-06-05 05:30:36 -04:00
|
|
|
100.times { s.sample(rand(30)); t.tick }
|
2006-03-26 15:01:50 -05:00
|
|
|
|
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
|