about summary refs log tree commit homepage
path: root/test/unit/test_stats.rb
diff options
context:
space:
mode:
authorevanweaver <evanweaver@19e92222-5c0b-0410-8929-a290d50e31e9>2008-05-24 23:06:53 +0000
committerevanweaver <evanweaver@19e92222-5c0b-0410-8929-a290d50e31e9>2008-05-24 23:06:53 +0000
commit45ff7b22b67123dd8345f3c50151e89cc91ce2b7 (patch)
treee85c8aa353e3e9f05e90ee8bf76a6593520e1b01 /test/unit/test_stats.rb
parentf69f3602b11dc839bb09f8c783b5ec27c54694fd (diff)
parentfa3f48f65222eb5591ef3dd9c05b6c958d564fa4 (diff)
downloadunicorn-45ff7b22b67123dd8345f3c50151e89cc91ce2b7.tar.gz
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@1020 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'test/unit/test_stats.rb')
-rw-r--r--test/unit/test_stats.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/unit/test_stats.rb b/test/unit/test_stats.rb
new file mode 100644
index 0000000..012c6a5
--- /dev/null
+++ b/test/unit/test_stats.rb
@@ -0,0 +1,35 @@
+# 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/test_helper'
+
+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