From c286952050e8fe16b0f6d64ba0687b52cc8f2ae1 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 14 May 2009 01:56:07 -0700 Subject: Minimal base/new_base comparison --- actionpack/examples/minimal.rb | 34 ++++++++++++++++++++++++++++++++++ actionpack/examples/simple.rb | 17 ----------------- 2 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 actionpack/examples/minimal.rb delete mode 100644 actionpack/examples/simple.rb (limited to 'actionpack/examples') diff --git a/actionpack/examples/minimal.rb b/actionpack/examples/minimal.rb new file mode 100644 index 0000000000..84a8499daf --- /dev/null +++ b/actionpack/examples/minimal.rb @@ -0,0 +1,34 @@ +$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" +require 'action_controller' +require 'action_controller/new_base' if ENV['NEW'] +require 'benchmark' + +class BaseController < ActionController::Base + def index + render :text => '' + end +end + +n = (ENV['N'] || 10000).to_i +input = StringIO.new('') + +def call_index(controller, input, n) + n.times do + controller.action(:index).call({ 'rack.input' => input }) + end + + puts controller.name + status, headers, body = controller.action(:index).call({ 'rack.input' => input }) + + puts status + puts headers.to_yaml + puts '---' + body.each do |part| + puts part + end + puts '---' +end + +elapsed = Benchmark.realtime { call_index BaseController, input, n } + +puts "%dms elapsed, %d requests/sec" % [1000 * elapsed, n / elapsed] diff --git a/actionpack/examples/simple.rb b/actionpack/examples/simple.rb deleted file mode 100644 index 4ecb824688..0000000000 --- a/actionpack/examples/simple.rb +++ /dev/null @@ -1,17 +0,0 @@ -$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" -require 'action_controller' - -class PeopleController < ActionController::Base - def index - head :ok - end -end - -status, headers, body = PeopleController.action(:index).call({ 'rack.input' => StringIO.new('') }) - -puts status -puts headers.to_yaml -puts '---' -body.each do |part| - puts part -end -- cgit v1.2.3