diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-01-19 05:24:44 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-01-19 05:24:44 +0000 |
commit | 630c643f5ba37cbaf541f72005e49080545bcada (patch) | |
tree | 9144f46dd3a9011396944b78afd2aa67242dcd7e /actionpack | |
parent | 355a8ff2cded22dafaa83c4578d21037eea2ca9c (diff) | |
download | rails-630c643f5ba37cbaf541f72005e49080545bcada.tar.gz rails-630c643f5ba37cbaf541f72005e49080545bcada.tar.bz2 rails-630c643f5ba37cbaf541f72005e49080545bcada.zip |
Add timing test for large restful route recognition. References #10835 [oleganza]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8673 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/controller/fake_controllers.rb | 17 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 43 |
2 files changed, 52 insertions, 8 deletions
diff --git a/actionpack/test/controller/fake_controllers.rb b/actionpack/test/controller/fake_controllers.rb index 5f958b2845..75c114c103 100644 --- a/actionpack/test/controller/fake_controllers.rb +++ b/actionpack/test/controller/fake_controllers.rb @@ -10,6 +10,23 @@ module Admin class NewsFeedController < Class.new(ActionController::Base); end end +# For speed test +class SpeedController < ActionController::Base; end +class SearchController < SpeedController; end +class VideosController < SpeedController; end +class VideoFileController < SpeedController; end +class VideoSharesController < SpeedController; end +class VideoAbusesController < SpeedController; end +class VideoUploadsController < SpeedController; end +class VideoVisitsController < SpeedController; end +class UsersController < SpeedController; end +class SettingsController < SpeedController; end +class ChannelsController < SpeedController; end +class ChannelVideosController < SpeedController; end +class SessionsController < SpeedController; end +class LostPasswordsController < SpeedController; end +class PagesController < SpeedController; end + ActionController::Routing::Routes.draw do |map| map.route_one 'route_one', :controller => 'elsewhere', :action => 'flash_me' map.connect ':controller/:action/:id' diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index fa467f0796..73b1fa55e8 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -84,20 +84,47 @@ class LegacyRouteSetTests < Test::Unit::TestCase end def test_time_recognition - n = 10000 + # We create many routes to make situation more realistic + @rs = ::ActionController::Routing::RouteSet.new + @rs.draw { |map| + map.frontpage '', :controller => 'search', :action => 'new' + map.resources :videos do |video| + video.resources :comments + video.resource :file, :controller => 'video_file' + video.resource :share, :controller => 'video_shares' + video.resource :abuse, :controller => 'video_abuses' + end + map.resources :abuses, :controller => 'video_abuses' + map.resources :video_uploads + map.resources :video_visits + + map.resources :users do |user| + user.resource :settings + user.resources :videos + end + map.resources :channels do |channel| + channel.resources :videos, :controller => 'channel_videos' + end + map.resource :session + map.resource :lost_password + map.search 'search', :controller => 'search' + map.resources :pages + map.connect ':controller/:action/:id' + } + n = 1000 if RunTimeTests GC.start rectime = Benchmark.realtime do n.times do - rs.recognize_path("content") - rs.recognize_path("content/list") - rs.recognize_path("content/show/10") - rs.recognize_path("admin/user") - rs.recognize_path("admin/user/list") - rs.recognize_path("admin/user/show/10") + 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 (RouteSet):" + 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" |