mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
e1d423ab4d
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@349 19e92222-5c0b-0410-8929-a290d50e31e9
37 lines
812 B
Ruby
37 lines
812 B
Ruby
# 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.
|
|
|
|
require 'test/unit'
|
|
require 'mongrel/stats'
|
|
require 'stringio'
|
|
|
|
class StatsTest < Test::Unit::TestCase
|
|
|
|
def test_sampling_speed
|
|
out = StringIO.new
|
|
|
|
s = Mongrel::Stats.new("test")
|
|
t = Mongrel::Stats.new("time")
|
|
|
|
100.times { s.sample(rand(20)); t.tick }
|
|
|
|
s.dump("FIRST", out)
|
|
t.dump("FIRST", out)
|
|
|
|
old_mean = s.mean
|
|
old_sd = s.sd
|
|
|
|
s.reset
|
|
t.reset
|
|
100.times { s.sample(rand(30)); t.tick }
|
|
|
|
s.dump("SECOND", out)
|
|
t.dump("SECOND", out)
|
|
assert_not_equal old_mean, s.mean
|
|
assert_not_equal old_mean, s.sd
|
|
end
|
|
|
|
end
|