13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/benchmark-interface/backends/simple.rb', line 13
def self.run(benchmark_set, names, options)
loop_time = options['--time']
benchmark_set.benchmarks(names).each do |benchmark|
puts benchmark.name
block = benchmark.block
start_time = Time.now
while Time.now - start_time < loop_time
start_iteration_time = Time.now
iterations = 0
while Time.now - start_iteration_time < 1
block.call
iterations += 1
end
iteration_time = Time.now - start_iteration_time
iterations *= benchmark_set.iterations
puts iterations / iteration_time
end
end
end
|