Class: Benny::DSL::Definition
- Inherits:
-
Object
- Object
- Benny::DSL::Definition
- Defined in:
- lib/benny/dsl.rb
Defined Under Namespace
Classes: BenchmarkEntry, WarmupOptions
Instance Attribute Summary collapse
-
#before_blocks ⇒ Object
readonly
Returns the value of attribute before_blocks.
-
#benchmarks ⇒ Object
readonly
Returns the value of attribute benchmarks.
-
#warmup_options ⇒ Object
readonly
Returns the value of attribute warmup_options.
Instance Method Summary collapse
- #before(&block) ⇒ Object
- #benchmark(name, &block) ⇒ Object
-
#initialize(&block) ⇒ Definition
constructor
A new instance of Definition.
- #warmup(iterations:) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Definition
Returns a new instance of Definition.
26 27 28 29 30 31 |
# File 'lib/benny/dsl.rb', line 26 def initialize(&block) @before_blocks = [] @benchmarks = [] @warmup_options = WarmupOptions.new(iterations: 1) instance_eval(&block) end |
Instance Attribute Details
#before_blocks ⇒ Object (readonly)
Returns the value of attribute before_blocks.
24 25 26 |
# File 'lib/benny/dsl.rb', line 24 def before_blocks @before_blocks end |
#benchmarks ⇒ Object (readonly)
Returns the value of attribute benchmarks.
24 25 26 |
# File 'lib/benny/dsl.rb', line 24 def benchmarks @benchmarks end |
#warmup_options ⇒ Object (readonly)
Returns the value of attribute warmup_options.
24 25 26 |
# File 'lib/benny/dsl.rb', line 24 def @warmup_options end |
Instance Method Details
#before(&block) ⇒ Object
37 38 39 |
# File 'lib/benny/dsl.rb', line 37 def before(&block) @before_blocks << block end |
#benchmark(name, &block) ⇒ Object
41 42 43 |
# File 'lib/benny/dsl.rb', line 41 def benchmark(name, &block) @benchmarks << BenchmarkEntry.new(self, name, &block) end |
#warmup(iterations:) ⇒ Object
33 34 35 |
# File 'lib/benny/dsl.rb', line 33 def warmup(iterations:) @warmup_options = WarmupOptions.new(iterations: iterations) end |