OSDN Git Service

ActiveLdap 1.2.4
[redminele/redminele.git] / ruby / lib / ruby / gems / 1.8 / gems / mongrel-1.1.5-x86-mswin32-60 / test / test_stats.rb
1 # Copyright (c) 2005 Zed A. Shaw 
2 # You can redistribute it and/or modify it under the same terms as Ruby.
3 #
4 # Additional work donated by contributors.  See http://mongrel.rubyforge.org/attributions.html 
5 # for more information.
6
7 require 'test/testhelp'
8
9 class StatsTest < Test::Unit::TestCase
10
11   def test_sampling_speed
12     out = StringIO.new
13
14     s = Mongrel::Stats.new("test")
15     t = Mongrel::Stats.new("time")
16
17     100.times { s.sample(rand(20)); t.tick }
18
19     s.dump("FIRST", out)
20     t.dump("FIRST", out)
21     
22     old_mean = s.mean
23     old_sd = s.sd
24
25     s.reset
26     t.reset
27     100.times { s.sample(rand(30)); t.tick }
28     
29     s.dump("SECOND", out)
30     t.dump("SECOND", out)
31     assert_not_equal old_mean, s.mean
32     assert_not_equal old_mean, s.sd    
33   end
34
35 end