From 06c0892040834c8c03f14217351049e27b0848e6 Mon Sep 17 00:00:00 2001 From: evanweaver Date: Mon, 22 Oct 2007 16:46:23 +0000 Subject: classifier faster yet because we don't need to rebuild that string git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@736 19e92222-5c0b-0410-8929-a290d50e31e9 --- test/test_uriclassifier.rb | 95 ++++++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 46 deletions(-) (limited to 'test') 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 -- cgit v1.2.3-24-ge0c7