Last active
August 29, 2015 14:16
-
-
Save rShetty/d9a15645697aa2632037 to your computer and use it in GitHub Desktop.
Benchmark IPS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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