blob: 84a8499daf4433ace494ab2b0a103c105e7a3b28 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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]
|