Permalink
Browse files

Updates to benchmark harness.

  • Loading branch information...
1 parent b05c951 commit e8849203dc68d1a2fabf5e6b51b379ad1c51f8c8 @wycats wycats committed Aug 9, 2009
Showing with 23 additions and 2 deletions.
  1. +23 −2 actionpack/examples/minimal.rb
@@ -6,6 +6,7 @@
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../activesupport/lib"
require 'action_controller'
require 'action_controller/new_base' if ENV['NEW']
+require 'action_view'
require 'benchmark'
class Runner
@@ -37,9 +38,19 @@ def self.run(app, n, label = nil)
N = (ENV['N'] || 1000).to_i
+module ActionController::Rails2Compatibility
+ instance_methods.each do |name|
+ remove_method name
+ end
+end
+
class BasePostController < ActionController::Base
append_view_path "#{File.dirname(__FILE__)}/views"
+ def overhead
+ self.response_body = ''
+ end
+
def index
render :text => ''
end
@@ -71,17 +82,27 @@ def index
end
unless ENV["PROFILE"]
+ Runner.run(BasePostController.action(:overhead), N, 'overhead')
+ Runner.run(BasePostController.action(:index), N, 'index')
+ 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')
+
(ENV["M"] || 1).to_i.times do
+ Runner.run(BasePostController.action(:overhead), N, 'overhead')
+ Runner.run(BasePostController.action(:index), N, 'index')
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')
end
else
+ Runner.run(BasePostController.action(:many_partials), N, 'many_partials')
require "ruby-prof"
RubyProf.start
- Runner.run(BasePostController.action(:many_partials), N, 'partial')
+ Runner.run(BasePostController.action(:many_partials), N, 'many_partials')
result = RubyProf.stop
printer = RubyProf::CallStackPrinter.new(result)
- printer.print(File.open("output.html", "w"), :min_percent => 2)
+ printer.print(File.open("output.html", "w"))
end

0 comments on commit e884920

Please sign in to comment.