11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/project/benchmark.rb', line 11
def run_single(setup_desc, code_desc, iterations, &block)
@total_run ||= 0
start_time = Time.milliseconds_since_epoch
iterations.times do
@total_run += 1
block.call
end
end_time = Time.milliseconds_since_epoch
total_time = end_time - start_time
per_item = total_time / iterations.to_f
out = "\nBenchmark Started at: #{decimal_formatter.format(start_time)}"
out << "\n Iterations: #{decimal_formatter.format(iterations)}"
out << "\n Setup: #{setup_desc}\n Code: #{code_desc}"
out << "\n Total milliseconds: #{decimal_formatter.format(total_time)}"
out << "\n Milliseconds per iteration: #{per_item}"
out << "\n RMQ allocations: #{$rmq_initialized.to_s}"
mp out
Potion::System.gc
out
end
|