Class: Hone::HarnessRunner
- Inherits:
-
Object
- Object
- Hone::HarnessRunner
- Defined in:
- lib/hone/harness_runner.rb
Constant Summary collapse
- PROFILE_DIR =
"tmp/hone"
Instance Attribute Summary collapse
-
#harness_path ⇒ Object
readonly
Returns the value of attribute harness_path.
-
#include_memory ⇒ Object
readonly
Returns the value of attribute include_memory.
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
-
#profiler ⇒ Object
readonly
Returns the value of attribute profiler.
-
#warmup ⇒ Object
readonly
Returns the value of attribute warmup.
Instance Method Summary collapse
-
#initialize(harness_path, options = {}) ⇒ HarnessRunner
constructor
A new instance of HarnessRunner.
- #run ⇒ Object
Constructor Details
#initialize(harness_path, options = {}) ⇒ HarnessRunner
Returns a new instance of HarnessRunner.
12 13 14 15 16 17 18 |
# File 'lib/hone/harness_runner.rb', line 12 def initialize(harness_path, = {}) @harness_path = harness_path @profiler = [:profiler] || detect_profiler @include_memory = .fetch(:memory, false) @warmup = .fetch(:warmup, 10) @output_dir = .fetch(:output_dir, PROFILE_DIR) end |
Instance Attribute Details
#harness_path ⇒ Object (readonly)
Returns the value of attribute harness_path.
10 11 12 |
# File 'lib/hone/harness_runner.rb', line 10 def harness_path @harness_path end |
#include_memory ⇒ Object (readonly)
Returns the value of attribute include_memory.
10 11 12 |
# File 'lib/hone/harness_runner.rb', line 10 def include_memory @include_memory end |
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
10 11 12 |
# File 'lib/hone/harness_runner.rb', line 10 def output_dir @output_dir end |
#profiler ⇒ Object (readonly)
Returns the value of attribute profiler.
10 11 12 |
# File 'lib/hone/harness_runner.rb', line 10 def profiler @profiler end |
#warmup ⇒ Object (readonly)
Returns the value of attribute warmup.
10 11 12 |
# File 'lib/hone/harness_runner.rb', line 10 def warmup @warmup end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/hone/harness_runner.rb', line 20 def run harness = Harness.load(@harness_path) unless harness.valid? raise Hone::Error, "Harness must define an exercise block" end FileUtils.mkdir_p(@output_dir) # Setup phase (not profiled) harness.run_setup # Warmup phase (not profiled, lets JIT optimize) @warmup.times { harness.run_exercise } # Profile CPU cpu_path = profile_cpu(harness) # Profile memory (if requested) memory_path = @include_memory ? profile_memory(harness) : nil # Teardown phase harness.run_teardown # Write metadata (cpu_path, memory_path, harness.iterations) {cpu: cpu_path, memory: memory_path} end |