Class: ActionController::RequestProfiler::Sandbox

Inherits:
Object
  • Object
show all
Includes:
Integration::Runner
Defined in:
lib/action_controller/request_profiler.rb

Overview

Wrap up the integration session runner.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Integration::Runner

#copy_session_variables!, #method_missing, #open_session, #reset!

Constructor Details

#initialize(script_path) ⇒ Sandbox

Returns a new instance of Sandbox.



14
15
16
17
18
# File 'lib/action_controller/request_profiler.rb', line 14

def initialize(script_path)
  @quiet = false
  define_run_method(script_path)
  reset!
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActionController::Integration::Runner

Class Method Details

.benchmark(n, script) ⇒ Object



10
11
12
# File 'lib/action_controller/request_profiler.rb', line 10

def self.benchmark(n, script)
  new(script).benchmark(n)
end

Instance Method Details

#benchmark(n, profiling = false) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/action_controller/request_profiler.rb', line 20

def benchmark(n, profiling = false)
  @quiet = true
  print '  '

  result = Benchmark.realtime do
    n.times do |i|
      run(profiling)
      print_progress(i)
    end
  end

  puts
  result
ensure
  @quiet = false
end

#say(message) ⇒ Object



37
38
39
# File 'lib/action_controller/request_profiler.rb', line 37

def say(message)
  puts "  #{message}" unless @quiet
end