diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-05-24 17:34:40 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-05-24 17:34:40 -0700 |
commit | bdb61c1dadd64ad4e146228ac8048fd0034fa8cc (patch) | |
tree | ac58139bd3252049410f4473d6e57ea17170ff2a /actionpack/examples | |
parent | 6e039e863a5d71f2a516be2eef2605be23281290 (diff) | |
download | rails-bdb61c1dadd64ad4e146228ac8048fd0034fa8cc.tar.gz rails-bdb61c1dadd64ad4e146228ac8048fd0034fa8cc.tar.bz2 rails-bdb61c1dadd64ad4e146228ac8048fd0034fa8cc.zip |
Compare Base with Http
Diffstat (limited to 'actionpack/examples')
-rw-r--r-- | actionpack/examples/minimal.rb | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/actionpack/examples/minimal.rb b/actionpack/examples/minimal.rb index 0fc527445e..e2d112648c 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,31 @@ class Runner response[2].each { |part| out.puts part } out.puts '---' end + + def self.run(app, n) + env = { 'n' => n, 'rack.input' => StringIO.new(''), 'rack.errors' => $stdout } + t = Benchmark.realtime { new(app).call(env) } + puts "%d ms / %d req = %d usec/req" % [10**3 * t, n, 10**6 * t / n] + end +end + + +N = (ENV['N'] || 1000).to_i + +class BasePostController < ActionController::Base + def index + render :text => '' + end + + Runner.run(action(:index), N) end -n = (ENV['N'] || 1000).to_i -input = StringIO.new('') +if ActionController.const_defined?(:Http) + class HttpPostController < ActionController::Http + def index + self.response_body = '' + end -elapsed = Benchmark.realtime do - Runner.new(BaseController.action(:index)). - call('n' => n, 'rack.input' => input, 'rack.errors' => $stdout) + Runner.run(action(:index), N) + end end -puts "%dms elapsed, %d req/sec, %.2f msec/req" % - [1000 * elapsed, n / elapsed, 1000 * elapsed / n] |