Module: TestProf::Autopilot::Dsl
Overview
Module contains all available DSL instructions
Instance Method Summary collapse
-
#aggregate(number, &block) ⇒ Object
‘aggregate’ is used to run one profiler several times and merge results supported profilers – ‘stack_prof’.
-
#info(printable_object) ⇒ Object
‘info’ prints report printable_object; available printable objects – ‘report’.
-
#run(profiler, **options) ⇒ Object
‘run’ is used to start profiling profiler – uniq name of profiler; available profilers – :event_prof, :factory_prof, :stack_prof options; available options – :sample, :paths and :event (‘event_prof’ profiler only).
-
#save(report, **options) ⇒ Object
‘save’ writes report to file.
Instance Method Details
#aggregate(number, &block) ⇒ Object
‘aggregate’ is used to run one profiler several times and merge results supported profilers – ‘stack_prof’
example of using: aggregate(3) { run :stack_prof, sample: 100 }
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/test_prof/autopilot/dsl.rb', line 39 def aggregate(number, &block) raise ArgumentError, "Block is required!" unless block agg_report = nil number.times do block.call agg_report = agg_report.nil? ? report : agg_report.merge(report) end @report = agg_report end |
#info(printable_object) ⇒ Object
‘info’ prints report printable_object; available printable objects – ‘report’
55 56 57 |
# File 'lib/test_prof/autopilot/dsl.rb', line 55 def info(printable_object) Registry.fetch(:"#{printable_object.type}_printer").print_report(printable_object) end |
#run(profiler, **options) ⇒ Object
‘run’ is used to start profiling profiler – uniq name of profiler; available profilers – :event_prof, :factory_prof, :stack_prof options; available options – :sample, :paths and :event (‘event_prof’ profiler only)
26 27 28 29 30 31 32 |
# File 'lib/test_prof/autopilot/dsl.rb', line 26 def run(profiler, **) Logging.log "Executing 'run' with profiler:#{profiler} and options:#{}" executor = Registry.fetch(:"#{profiler}_executor").new().start @report = executor.report end |