Update minimal.rb to benchmark partials
This commit is contained in:
parent
d7415f792c
commit
b57d94c187
@ -3,6 +3,7 @@
|
||||
ENV['NO_RELOAD'] ||= '1'
|
||||
|
||||
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
||||
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../activesupport/lib"
|
||||
require 'action_controller'
|
||||
require 'action_controller/new_base' if ENV['NEW']
|
||||
require 'benchmark'
|
||||
@ -26,7 +27,7 @@ def report(env, response)
|
||||
|
||||
def self.run(app, n, label = nil)
|
||||
puts '=' * label.size, label, '=' * label.size if label
|
||||
env = { 'n' => n, 'rack.input' => StringIO.new(''), 'rack.errors' => $stdout }
|
||||
env = Rack::MockRequest.env_for("/").merge('n' => n, 'rack.input' => StringIO.new(''), 'rack.errors' => $stdout)
|
||||
t = Benchmark.realtime { new(app).call(env) }
|
||||
puts "%d ms / %d req = %.1f usec/req" % [10**3 * t, n, 10**6 * t / n]
|
||||
puts
|
||||
@ -37,9 +38,27 @@ def self.run(app, n, label = nil)
|
||||
N = (ENV['N'] || 1000).to_i
|
||||
|
||||
class BasePostController < ActionController::Base
|
||||
append_view_path "#{File.dirname(__FILE__)}/views"
|
||||
|
||||
def index
|
||||
render :text => ''
|
||||
end
|
||||
|
||||
def partial
|
||||
render :partial => "/partial"
|
||||
end
|
||||
|
||||
def many_partials
|
||||
render :partial => "/many_partials"
|
||||
end
|
||||
|
||||
def partial_collection
|
||||
render :partial => "/collection", :collection => [1,2,3,4,5,6,7,8,9,10]
|
||||
end
|
||||
|
||||
def show_template
|
||||
render :template => "template"
|
||||
end
|
||||
end
|
||||
|
||||
OK = [200, {}, []]
|
||||
@ -51,6 +70,10 @@ def index
|
||||
end
|
||||
end
|
||||
|
||||
Runner.run(MetalPostController, N, 'metal')
|
||||
Runner.run(HttpPostController.action(:index), N, 'http') if defined? HttpPostController
|
||||
Runner.run(BasePostController.action(:index), N, 'base')
|
||||
# Runner.run(MetalPostController, N, 'metal')
|
||||
# Runner.run(HttpPostController.action(:index), N, 'http') if defined? HttpPostController
|
||||
# Runner.run(BasePostController.action(:index), N, 'base')
|
||||
Runner.run(BasePostController.action(:partial), N, 'partial')
|
||||
Runner.run(BasePostController.action(:many_partials), N, 'many_partials')
|
||||
Runner.run(BasePostController.action(:partial_collection), N, 'collection')
|
||||
Runner.run(BasePostController.action(:show_template), N, 'template')
|
||||
|
1
actionpack/examples/views/_collection.erb
Normal file
1
actionpack/examples/views/_collection.erb
Normal file
@ -0,0 +1 @@
|
||||
<%= collection %>
|
1
actionpack/examples/views/_hello.erb
Normal file
1
actionpack/examples/views/_hello.erb
Normal file
@ -0,0 +1 @@
|
||||
Hello
|
10
actionpack/examples/views/_many_partials.erb
Normal file
10
actionpack/examples/views/_many_partials.erb
Normal file
@ -0,0 +1,10 @@
|
||||
<%= render :partial => '/hello' %>
|
||||
<%= render :partial => '/hello' %>
|
||||
<%= render :partial => '/hello' %>
|
||||
<%= render :partial => '/hello' %>
|
||||
<%= render :partial => '/hello' %>
|
||||
<%= render :partial => '/hello' %>
|
||||
<%= render :partial => '/hello' %>
|
||||
<%= render :partial => '/hello' %>
|
||||
<%= render :partial => '/hello' %>
|
||||
<%= render :partial => '/hello' %>
|
10
actionpack/examples/views/_partial.erb
Normal file
10
actionpack/examples/views/_partial.erb
Normal file
@ -0,0 +1,10 @@
|
||||
<%= "Hello" %>
|
||||
<%= "Hello" %>
|
||||
<%= "Hello" %>
|
||||
<%= "Hello" %>
|
||||
<%= "Hello" %>
|
||||
<%= "Hello" %>
|
||||
<%= "Hello" %>
|
||||
<%= "Hello" %>
|
||||
<%= "Hello" %>
|
||||
<%= "Hello" %>
|
@ -1 +1 @@
|
||||
Hello <%= @name %>
|
||||
Hello
|
Loading…
Reference in New Issue
Block a user