Module: TestProf::Autopilot::Dsl

Included in:
Merger, Runner
Defined in:
lib/test_prof/autopilot/dsl.rb

Overview

Module contains all available DSL instructions

Instance Method Summary collapse

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 }

Raises:

  • (ArgumentError)


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, **options)
  Logging.log "Executing 'run' with profiler:#{profiler} and options:#{options}"

  executor = Registry.fetch(:"#{profiler}_executor").new(options).start

  @report = executor.report
end

#save(report, **options) ⇒ Object

‘save’ writes report to file



60
61
62
# File 'lib/test_prof/autopilot/dsl.rb', line 60

def save(report, **options)
  Registry.fetch(:"#{report.type}_writer").write_report(report, **options)
end