Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Benchmark IPS
require 'benchmark/ips'
Benchmark.ips do |x|
x.config(:time => 5, :warmup => 2)
x.time = 5
x.warmup = 2
times = 10000
x.report("report_1") do
times.times do
(('a'..'z').to_a + ('0'..'9').to_a).repeated_permutation(2).to_a.sample(1).join
end
end
x.report("report_2") do
times.times do
(('a'..'z').to_a + ('0'..'9').to_a).sample(2).join
end
end
x.compare!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.