4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/haystack_worker/benchmark.rb', line 4
def benchmark(exponentials = 5..7)
puts "\n::::: Benchmarking :::::\n\n"
exponentials.map do |i|
number_of_attempts = 10 ** i
attempts = [1..10] * i + [1..1] * (26 - i)
puts "Job size: #{number_of_attempts}\n\n"
times = 5.times.map do
time = Benchmark.realtime do
surpluses(attempts)
end
puts time
time
end
average = times.inject(:+) / times.size
puts "\nAverage: #{average}"
rate = (number_of_attempts / average).round
puts "Rate: #{rate} attempts/s/thread\n\n"
end
end
|