Class: FastCov::Benchmark::Runner
- Inherits:
-
Object
- Object
- FastCov::Benchmark::Runner
- Defined in:
- lib/fast_cov/benchmark/runner.rb
Constant Summary collapse
- DEFAULT_ITERATIONS =
1000- DEFAULT_SAMPLES =
5- WARMUP_ITERATIONS =
20
Instance Attribute Summary collapse
-
#baseline_path ⇒ Object
readonly
Returns the value of attribute baseline_path.
-
#iterations ⇒ Object
readonly
Returns the value of attribute iterations.
-
#samples ⇒ Object
readonly
Returns the value of attribute samples.
Instance Method Summary collapse
-
#initialize(iterations: DEFAULT_ITERATIONS, samples: DEFAULT_SAMPLES, baseline_path: nil) ⇒ Runner
constructor
A new instance of Runner.
- #run(save_baseline: false) ⇒ Object
- #scenario(name, &block) ⇒ Object
Constructor Details
#initialize(iterations: DEFAULT_ITERATIONS, samples: DEFAULT_SAMPLES, baseline_path: nil) ⇒ Runner
Returns a new instance of Runner.
15 16 17 18 19 20 |
# File 'lib/fast_cov/benchmark/runner.rb', line 15 def initialize(iterations: DEFAULT_ITERATIONS, samples: DEFAULT_SAMPLES, baseline_path: nil) @iterations = iterations @samples = samples @baseline_path = baseline_path || default_baseline_path @scenarios = [] end |
Instance Attribute Details
#baseline_path ⇒ Object (readonly)
Returns the value of attribute baseline_path.
13 14 15 |
# File 'lib/fast_cov/benchmark/runner.rb', line 13 def baseline_path @baseline_path end |
#iterations ⇒ Object (readonly)
Returns the value of attribute iterations.
13 14 15 |
# File 'lib/fast_cov/benchmark/runner.rb', line 13 def iterations @iterations end |
#samples ⇒ Object (readonly)
Returns the value of attribute samples.
13 14 15 |
# File 'lib/fast_cov/benchmark/runner.rb', line 13 def samples @samples end |
Instance Method Details
#run(save_baseline: false) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fast_cov/benchmark/runner.rb', line 26 def run(save_baseline: false) baseline = load_baseline unless save_baseline results = run_scenarios print_results(results, baseline) if save_baseline save_baseline_to_disk(results) elsif baseline puts "Baseline: #{@baseline_path} (saved #{baseline["saved_at"]})" else puts "No baseline found. Run with --baseline to save one." end end |
#scenario(name, &block) ⇒ Object
22 23 24 |
# File 'lib/fast_cov/benchmark/runner.rb', line 22 def scenario(name, &block) @scenarios << { name: name, block: block } end |