about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorevanweaver <evanweaver@19e92222-5c0b-0410-8929-a290d50e31e9>2007-10-22 16:46:23 +0000
committerevanweaver <evanweaver@19e92222-5c0b-0410-8929-a290d50e31e9>2007-10-22 16:46:23 +0000
commit06c0892040834c8c03f14217351049e27b0848e6 (patch)
treedae15d89be2bd61295dc27ce06f10d460a168856 /test
parent7192a5ec5895f5ded477178efe53b289ec5435a6 (diff)
downloadunicorn-06c0892040834c8c03f14217351049e27b0848e6.tar.gz
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@736 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'test')
-rw-r--r--test/test_uriclassifier.rb95
1 files changed, 49 insertions, 46 deletions
diff --git a/test/test_uriclassifier.rb b/test/test_uriclassifier.rb
index 2acb042..7dfd04f 100644
--- a/test/test_uriclassifier.rb
+++ b/test/test_uriclassifier.rb
@@ -193,56 +193,59 @@ class URIClassifierTest < Test::Unit::TestCase
     end
   end
   
-  def xtest_benchmark    
-    # This benchmark should favor a TST, but it seems to be mostly irrelevant
-  
-    @uris = %w(
-      /
-      /dag /dig /digbark /dog /dogbark /dog/bark /dug /dugbarking /puppy
-      /c /cat /cat/tree /cat/tree/mulberry /cats /cot /cot/tree/mulberry /kitty /kittycat
-    )
+  if ENV['BENCHMARK']
+    # Eventually we will have a suite of benchmarks instead of lamely installing a test
     
-    @requests = %w(
-      /
-      /dig
-      /digging
-      /dogging
-      /dogbarking/
-      /puppy/barking
-      /c
-      /cat
-      /cat/shrub
-      /cat/tree
-      /cat/tree/maple
-      /cat/tree/mulberry/tree
-      /cat/tree/oak
-      /cats/
-      /cats/tree
-      /cod
-      /zebra
-    )
-  
-    @classifier = URIClassifier.new
-    @uris.each do |uri|
-      @classifier.register(uri, 1)
-    end
+    def test_benchmark    
+
+      # This URI scheme should favor a TST, but it seems to be mostly irrelevant    
+      @uris = %w(
+        /
+        /dag /dig /digbark /dog /dogbark /dog/bark /dug /dugbarking /puppy
+        /c /cat /cat/tree /cat/tree/mulberry /cats /cot /cot/tree/mulberry /kitty /kittycat
+      )
+      
+      @requests = %w(
+        /
+        /dig
+        /digging
+        /dogging
+        /dogbarking/
+        /puppy/barking
+        /c
+        /cat
+        /cat/shrub
+        /cat/tree
+        /cat/tree/maple
+        /cat/tree/mulberry/tree
+        /cat/tree/oak
+        /cats/
+        /cats/tree
+        /cod
+        /zebra
+      )
     
-    puts "#{@uris.size} URIs / #{@requests.size * 10000} requests"
-
-    Benchmark.bm do |x|
-      x.report do
-#        require 'ruby-prof'
-#        profile = RubyProf.profile do
-          10000.times do
-            @requests.each do |request|
-              @classifier.resolve(request)
-            end
-          end
-#        end
-#        File.open("profile.html", 'w') { |file| RubyProf::GraphHtmlPrinter.new(profile).print(file, 0) }
+      @classifier = URIClassifier.new
+      @uris.each do |uri|
+        @classifier.register(uri, 1)
       end
+      
+      puts "#{@uris.size} URIs / #{@requests.size * 10000} requests"
+  
+      Benchmark.bm do |x|
+        x.report do
+  #        require 'ruby-prof'
+  #        profile = RubyProf.profile do
+            10000.times do
+              @requests.each do |request|
+                @classifier.resolve(request)
+              end
+            end
+  #        end
+  #        File.open("profile.html", 'w') { |file| RubyProf::GraphHtmlPrinter.new(profile).print(file, 0) }
+        end
+      end          
     end
-        
   end
   
 end