Skip to content

Commit

Permalink
Kill routing timed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Aug 14, 2009
1 parent c6bc8e6 commit f86a4b8
Showing 1 changed file with 3 additions and 50 deletions.
53 changes: 3 additions & 50 deletions actionpack/test/controller/routing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def index() head :ok end
def rescue_action(e) raise e end
end

RunTimeTests = ARGV.include? 'time'
ROUTING = ActionController::Routing

class ROUTING::RouteBuilder
Expand Down Expand Up @@ -759,7 +758,7 @@ def setup

ActionController::Routing.use_controllers! %w(content admin/user admin/news_feed)
end

def teardown
@rs.clear!
end
Expand Down Expand Up @@ -815,52 +814,6 @@ def test_time_recognition
map.resources :pages
map.connect ':controller/:action/:id'
}
n = 1000
if RunTimeTests
GC.start
rectime = Benchmark.realtime do
n.times do
rs.recognize_path("/videos/1234567", {:method => :get})
rs.recognize_path("/videos/1234567/abuse", {:method => :get})
rs.recognize_path("/users/1234567/settings", {:method => :get})
rs.recognize_path("/channels/1234567", {:method => :get})
rs.recognize_path("/session/new", {:method => :get})
rs.recognize_path("/admin/user/show/10", {:method => :get})
end
end
puts "\n\nRecognition (#{rs.routes.size} routes):"
per_url = rectime / (n * 6)
puts "#{per_url * 1000} ms/url"
puts "#{1 / per_url} url/s\n\n"
end
end

def test_time_generation
n = 5000
if RunTimeTests
GC.start
pairs = [
[{:controller => 'content', :action => 'index'}, {:controller => 'content', :action => 'show'}],
[{:controller => 'content'}, {:controller => 'content', :action => 'index'}],
[{:controller => 'content', :action => 'list'}, {:controller => 'content', :action => 'index'}],
[{:controller => 'content', :action => 'show', :id => '10'}, {:controller => 'content', :action => 'list'}],
[{:controller => 'admin/user', :action => 'index'}, {:controller => 'admin/user', :action => 'show'}],
[{:controller => 'admin/user'}, {:controller => 'admin/user', :action => 'index'}],
[{:controller => 'admin/user', :action => 'list'}, {:controller => 'admin/user', :action => 'index'}],
[{:controller => 'admin/user', :action => 'show', :id => '10'}, {:controller => 'admin/user', :action => 'list'}],
]
p = nil
gentime = Benchmark.realtime do
n.times do
pairs.each {|(a, b)| rs.generate(a, b)}
end
end

puts "\n\nGeneration (RouteSet): (#{(n * 8)} urls)"
per_url = gentime / (n * 8)
puts "#{per_url * 1000} ms/url"
puts "#{1 / per_url} url/s\n\n"
end
end

def test_route_with_colon_first
Expand Down Expand Up @@ -2567,10 +2520,10 @@ def test_load_with_configuration

routes.reload
end

def test_load_multiple_configurations
routes.add_configuration_file("engines.rb")

File.expects(:stat).at_least_once.returns(@stat)

routes.expects(:load).with('./config/routes.rb')
Expand Down

0 comments on commit f86a4b8

Please sign in to comment.