diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-06-01 09:38:09 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-06-01 09:38:09 +0100 |
commit | 9d60525b5fc14b4b6f3ed9ba8ea874d6e76b4f78 (patch) | |
tree | 5a711cacac76a83ad12551023da8524f94e7365b /actionpack/examples/minimal.rb | |
parent | dc7323efd34327c13d26031b68e51314c24360f6 (diff) | |
parent | 9537fd0e3a7625afe4bee75d749647ca1837195a (diff) | |
download | rails-9d60525b5fc14b4b6f3ed9ba8ea874d6e76b4f78.tar.gz rails-9d60525b5fc14b4b6f3ed9ba8ea874d6e76b4f78.tar.bz2 rails-9d60525b5fc14b4b6f3ed9ba8ea874d6e76b4f78.zip |
Merge commit 'mainstream/master'
Diffstat (limited to 'actionpack/examples/minimal.rb')
-rw-r--r-- | actionpack/examples/minimal.rb | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/actionpack/examples/minimal.rb b/actionpack/examples/minimal.rb index 0fc527445e..9eb92cd8e7 100644 --- a/actionpack/examples/minimal.rb +++ b/actionpack/examples/minimal.rb @@ -7,12 +7,6 @@ require 'action_controller' require 'action_controller/new_base' if ENV['NEW'] require 'benchmark' -class BaseController < ActionController::Base - def index - render :text => '' - end -end - class Runner def initialize(app) @app = app @@ -29,14 +23,36 @@ class Runner response[2].each { |part| out.puts part } out.puts '---' end + + 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 } + t = Benchmark.realtime { new(app).call(env) } + puts "%d ms / %d req = %.1f usec/req" % [10**3 * t, n, 10**6 * t / n] + puts + end +end + + +N = (ENV['N'] || 1000).to_i + +class BasePostController < ActionController::Base + def index + render :text => '' + end end -n = (ENV['N'] || 1000).to_i -input = StringIO.new('') +OK = [200, {}, []] +MetalPostController = lambda { OK } -elapsed = Benchmark.realtime do - Runner.new(BaseController.action(:index)). - call('n' => n, 'rack.input' => input, 'rack.errors' => $stdout) +if ActionController.const_defined?(:Http) + class HttpPostController < ActionController::Http + def index + self.response_body = '' + end + end end -puts "%dms elapsed, %d req/sec, %.2f msec/req" % - [1000 * elapsed, n / elapsed, 1000 * elapsed / n] + +Runner.run(MetalPostController, N, 'metal') +Runner.run(HttpPostController.action(:index), N, 'http') if defined? HttpPostController +Runner.run(BasePostController.action(:index), N, 'base') |