Module: Viiite::Benchmark::Runner

Included in:
Viiite::Benchmark
Defined in:
lib/viiite/benchmark/runner.rb

Instance Method Summary collapse

Instance Method Details

#range_over(range, name) ⇒ Object



17
18
19
20
21
# File 'lib/viiite/benchmark/runner.rb', line 17

def range_over(range, name)
  range.each do |value|
    with(name => value){ yield value }
  end
end

#report(hash = {}, &block) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/viiite/benchmark/runner.rb', line 27

def report(hash = {}, &block)
  hash = {:bench => hash.to_sym} unless hash.is_a?(Hash)
  with(hash) {
    GC.start
    tms = Viiite.measure(&block)
    with(:tms => tms){ output }
  }
end

#variation_point(name, value, &proc) ⇒ Object



23
24
25
# File 'lib/viiite/benchmark/runner.rb', line 23

def variation_point(name, value, &proc)
  with({name => value}, &proc)
end

#with(hash) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/viiite/benchmark/runner.rb', line 5

def with(hash)
  if block_given?
    org_tuple = @tuple
    @tuple = org_tuple.merge(hash)
    res = yield
    @tuple = org_tuple
    res
  else
    @tuple.merge!(hash)
  end
end