Module: RuntimeProfiler
- Includes:
- ActiveSupport::Configurable
- Defined in:
- lib/runtime_profiler.rb,
lib/runtime_profiler/cli.rb,
lib/runtime_profiler/version.rb,
lib/runtime_profiler/profiler.rb,
lib/runtime_profiler/text_report.rb,
lib/runtime_profiler/events/sql_event.rb,
lib/runtime_profiler/instrumentation_data.rb,
lib/runtime_profiler/callbacks/active_record.rb,
lib/runtime_profiler/callbacks/action_controller.rb,
lib/runtime_profiler/events/process_action_event.rb
Defined Under Namespace
Modules: Callback
Classes: CLI, InstrumentationData, ProcessActionEvent, Profiler, SqlEvent, TextReport
Constant Summary
collapse
- VERSION =
'0.1.0'.freeze
Class Method Summary
collapse
Class Method Details
30
31
32
33
|
# File 'lib/runtime_profiler.rb', line 30
def configure
Rails.application.eager_load! rescue nil
yield self if block_given?
end
|
.profile!(key, konstants) ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'lib/runtime_profiler.rb', line 35
def profile!(key, konstants)
konstants = konstants.is_a?(Array) ? konstants : [konstants]
profiler = Profiler.new(konstants)
profiler.prepare_for_instrumentation
MethodMeter.measure!(key) { yield }
profiler.save_instrumentation_data
end
|
.runtime(label = 'for the block') ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/runtime_profiler.rb', line 45
def runtime(label='for the block')
result = nil
elapsed_time = Benchmark.realtime { result = yield }
puts
puts '~~~~> ELAPSED TIME (%s): %s' % [label, elapsed_time * 1000]
puts
result
end
|