about summary refs log tree commit homepage
path: root/test/test_stats.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_stats.rb')
-rw-r--r--test/test_stats.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_stats.rb b/test/test_stats.rb
new file mode 100644
index 0000000..4d6bc1a
--- /dev/null
+++ b/test/test_stats.rb
@@ -0,0 +1,28 @@
+require 'test/unit'
+require 'mongrel/stats'
+
+class StatsTest < Test::Unit::TestCase
+
+  def test_sampling_speed
+    s = Stats.new("test")
+    t = Stats.new("time")
+
+    10000.times { s.sample(rand(20)); t.tick }
+
+    s.dump("FIRST")
+    t.dump("FIRST")
+    
+    old_mean = s.mean
+    old_sd = s.sd
+
+    s.reset
+    t.reset
+    10000.times { s.sample(rand(20)); t.tick }
+    
+    s.dump("SECOND")
+    t.dump("SECOND")
+    assert_not_equal old_mean, s.mean
+    assert_not_equal old_mean, s.sd    
+  end
+
+end