Methods
A
C
D
N
P
R
Class Public methods
app_and_env_for(action, n)
# File actionpack/examples/performance.rb, line 47
def self.app_and_env_for(action, n)
  env = Rack::MockRequest.env_for("/")
  env.merge!('n' => n, 'rack.input' => StringIO.new(''), 'rack.errors' => $stdout)
  app = lambda { |env| BasePostController.action(action).call(env) }
  return app, env
end
done()
# File actionpack/examples/performance.rb, line 66
def self.done
  puts
  header, content = "", ""
  $ran.each do |k,v|
    size = [k.size, v.size].max + 1
    header << format("%#{size}s", k)
    content << format("%#{size}s", v)
  end
  puts header
  puts content
end
new(app, output)
# File actionpack/examples/performance.rb, line 18
def initialize(app, output)
  @app, @output = app, output
end
print(*)
# File actionpack/examples/performance.rb, line 43
def self.print(*)
  super if @output
end
puts(*)
# File actionpack/examples/performance.rb, line 39
def self.puts(*)
  super if @output
end
run(action, n, output = true)
# File actionpack/examples/performance.rb, line 56
def self.run(action, n, output = true)
  print "."
  STDOUT.flush
  @output = output
  label = action.to_s
  app, env = app_and_env_for(action, n)
  t = Benchmark.realtime { new(app, output).call(env) }
  $ran << [label, (t * 1000).to_i.to_s] if output
end
Instance Public methods
call(env)
# File actionpack/examples/performance.rb, line 26
def call(env)
  env['n'].to_i.times { @app.call(env) }
  @app.call(env).tap { |response| report(env, response) }
end
puts(*)
# File actionpack/examples/performance.rb, line 22
def puts(*)
  super if @output
end
report(env, response)
# File actionpack/examples/performance.rb, line 31
def report(env, response)
  return unless ENV["DEBUG"]
  out = env['rack.errors']
  out.puts response[0], response[1].to_yaml, '---'
  response[2].each { |part| out.puts part }
  out.puts '---'
end