aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-08-08 18:36:05 -0300
committerYehuda Katz <wycats@gmail.com>2009-08-09 04:12:08 -0300
commitb57d94c187965f8ef0994db9ba9f8b7bf1bf6591 (patch)
tree6e816df47b0849e127819d0d2b335b50e710f435 /actionpack
parentd7415f792cefeaa11453d7ac1d0c3813b2883599 (diff)
downloadrails-b57d94c187965f8ef0994db9ba9f8b7bf1bf6591.tar.gz
rails-b57d94c187965f8ef0994db9ba9f8b7bf1bf6591.tar.bz2
rails-b57d94c187965f8ef0994db9ba9f8b7bf1bf6591.zip
Update minimal.rb to benchmark partials
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/examples/minimal.rb31
-rw-r--r--actionpack/examples/views/_collection.erb1
-rw-r--r--actionpack/examples/views/_hello.erb1
-rw-r--r--actionpack/examples/views/_many_partials.erb10
-rw-r--r--actionpack/examples/views/_partial.erb10
-rw-r--r--actionpack/examples/views/template.html.erb2
6 files changed, 50 insertions, 5 deletions
diff --git a/actionpack/examples/minimal.rb b/actionpack/examples/minimal.rb
index 7106149fa2..01c64ba56b 100644
--- a/actionpack/examples/minimal.rb
+++ b/actionpack/examples/minimal.rb
@@ -3,6 +3,7 @@ ENV['RAILS_ENV'] ||= 'production'
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 @@ class Runner
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 @@ end
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 @@ class HttpPostController < ActionController::Metal
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')
diff --git a/actionpack/examples/views/_collection.erb b/actionpack/examples/views/_collection.erb
new file mode 100644
index 0000000000..bcfe958e2c
--- /dev/null
+++ b/actionpack/examples/views/_collection.erb
@@ -0,0 +1 @@
+<%= collection %> \ No newline at end of file
diff --git a/actionpack/examples/views/_hello.erb b/actionpack/examples/views/_hello.erb
new file mode 100644
index 0000000000..5ab2f8a432
--- /dev/null
+++ b/actionpack/examples/views/_hello.erb
@@ -0,0 +1 @@
+Hello \ No newline at end of file
diff --git a/actionpack/examples/views/_many_partials.erb b/actionpack/examples/views/_many_partials.erb
new file mode 100644
index 0000000000..7e379d46f5
--- /dev/null
+++ b/actionpack/examples/views/_many_partials.erb
@@ -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' %> \ No newline at end of file
diff --git a/actionpack/examples/views/_partial.erb b/actionpack/examples/views/_partial.erb
new file mode 100644
index 0000000000..3ca8e80b52
--- /dev/null
+++ b/actionpack/examples/views/_partial.erb
@@ -0,0 +1,10 @@
+<%= "Hello" %>
+<%= "Hello" %>
+<%= "Hello" %>
+<%= "Hello" %>
+<%= "Hello" %>
+<%= "Hello" %>
+<%= "Hello" %>
+<%= "Hello" %>
+<%= "Hello" %>
+<%= "Hello" %>
diff --git a/actionpack/examples/views/template.html.erb b/actionpack/examples/views/template.html.erb
index 3108e9ad70..5ab2f8a432 100644
--- a/actionpack/examples/views/template.html.erb
+++ b/actionpack/examples/views/template.html.erb
@@ -1 +1 @@
-Hello <%= @name %> \ No newline at end of file
+Hello \ No newline at end of file