Module: Small::Benchmark

Defined in:
lib/small/benchmark.rb

Instance Method Summary collapse

Instance Method Details

#benchmark(tab = 25) ⇒ Object



6
7
8
9
10
# File 'lib/small/benchmark.rb', line 6

def benchmark(tab = 25)
  ::Benchmark.bm(tab) do |b|
    yield b
  end
end

#measure(name = nil) ⇒ Object



12
13
14
# File 'lib/small/benchmark.rb', line 12

def measure(name = nil)
  ::Benchmark.measure(name) { yield }
end

#realtimeObject



16
17
18
# File 'lib/small/benchmark.rb', line 16

def realtime
  ::Benchmark.realtime { yield }
end

#run(n = 100_000) ⇒ Object



20
21
22
23
24
# File 'lib/small/benchmark.rb', line 20

def run(n = 100_000)
  n.to_i.times do |i|
    yield i
  end
end