Permalink
Browse files

add a metal to minimal examples for comparison

  • Loading branch information...
1 parent 7211048 commit 311d686d031bbc7074bddd8d56ea42780a204b35 @jeremy jeremy committed May 27, 2009
Showing with 11 additions and 6 deletions.
  1. +11 −6 actionpack/examples/minimal.rb
View
17 actionpack/examples/minimal.rb
@@ -24,10 +24,12 @@ def report(env, response)
out.puts '---'
end
- def self.run(app, n)
+ 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 = %d usec/req" % [10**3 * t, n, 10**6 * t / n]
+ puts "%d ms / %d req = %.1f usec/req" % [10**3 * t, n, 10**6 * t / n]
+ puts
end
end
@@ -38,16 +40,19 @@ class BasePostController < ActionController::Base
def index
render :text => ''
end
-
- Runner.run(action(:index), N)
end
+OK = [200, {}, []]
+MetalPostController = lambda { OK }
+
if ActionController.const_defined?(:Http)
class HttpPostController < ActionController::Http
def index
self.response_body = ''
end
-
- Runner.run(action(:index), N)
end
end
+
+Runner.run(MetalPostController, N, 'metal')
+Runner.run(HttpPostController.action(:index), N, 'http') if defined? HttpPostController
+Runner.run(BasePostController.action(:index), N, 'base')

0 comments on commit 311d686

Please sign in to comment.