Class: Benny::Executors::Benchmark
- Inherits:
-
Object
- Object
- Benny::Executors::Benchmark
- Defined in:
- lib/benny/executors/benchmark.rb
Instance Attribute Summary collapse
-
#benchmarks ⇒ Object
readonly
Returns the value of attribute benchmarks.
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
- #execute_one(benchmark) ⇒ Object
-
#initialize(benchmarks:, reporter:) ⇒ Benchmark
constructor
A new instance of Benchmark.
Constructor Details
#initialize(benchmarks:, reporter:) ⇒ Benchmark
Returns a new instance of Benchmark.
10 11 12 13 |
# File 'lib/benny/executors/benchmark.rb', line 10 def initialize(benchmarks:, reporter:) @benchmarks = benchmarks @reporter = reporter end |
Instance Attribute Details
#benchmarks ⇒ Object (readonly)
Returns the value of attribute benchmarks.
8 9 10 |
# File 'lib/benny/executors/benchmark.rb', line 8 def benchmarks @benchmarks end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
8 9 10 |
# File 'lib/benny/executors/benchmark.rb', line 8 def reporter @reporter end |
Class Method Details
.execute(benchmarks:, reporter:) ⇒ Object
35 36 37 |
# File 'lib/benny/executors/benchmark.rb', line 35 def self.execute(benchmarks:, reporter:) new(benchmarks: benchmarks, reporter: reporter).execute end |
Instance Method Details
#execute ⇒ Object
15 16 17 18 19 |
# File 'lib/benny/executors/benchmark.rb', line 15 def execute benchmarks.each do |benchmark| execute_one(benchmark) end end |
#execute_one(benchmark) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/benny/executors/benchmark.rb', line 21 def execute_one(benchmark) benchmark.definition.before_blocks.each(&:call) benchmark.definition..iterations.times do benchmark.block.call end measure = ::Benchmark.measure do benchmark.block.call end reporter.report(benchmark, measure) end |