Class: Benny::DSL::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/benny/dsl.rb

Defined Under Namespace

Classes: BenchmarkEntry, WarmupOptions

Instance Attribute Summary collapse

Instance Method Summary collapse

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_blocksObject (readonly)

Returns the value of attribute before_blocks.



24
25
26
# File 'lib/benny/dsl.rb', line 24

def before_blocks
  @before_blocks
end

#benchmarksObject (readonly)

Returns the value of attribute benchmarks.



24
25
26
# File 'lib/benny/dsl.rb', line 24

def benchmarks
  @benchmarks
end

#warmup_optionsObject (readonly)

Returns the value of attribute warmup_options.



24
25
26
# File 'lib/benny/dsl.rb', line 24

def warmup_options
  @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