Module: Object::WithBenchmark

Defined in:
lib/vex/base/object/with_benchmark.rb

Defined Under Namespace

Modules: Etest Classes: BenchmarkProxy

Instance Method Summary collapse

Instance Method Details

#benchmark(*args, &block) ⇒ Object


55
56
57
58
59
60
61
62
63
64
# File 'lib/vex/base/object/with_benchmark.rb', line 55

def benchmark(*args, &block)
  count = args.last.is_a?(Fixnum) ? args.pop : 1

  proxy = BenchmarkProxy.new self, *args, &block
  return proxy unless block_given?
  return proxy.yield(&block) if count <= 1
  return proxy.yield do 
    count.times(&block)
  end
end

#no_benchmark(*args, &block) ⇒ Object


51
52
53
# File 'lib/vex/base/object/with_benchmark.rb', line 51

def no_benchmark(*args, &block)
  block_given? ? yield : self
end

#yield(&block) ⇒ Object


66
# File 'lib/vex/base/object/with_benchmark.rb', line 66

def yield(&block); yield; end