-
-
Save cheald/d083c4d2e69580874bc0 to your computer and use it in GitHub Desktop.
This file contains 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 => 5) | |
x.report("times") { 6.times {|x| } } | |
x.report("range iteration") { (0..5).each {|x| } } | |
x.report("upto") { 0.upto(5) {|x| } } | |
x.report("for") do | |
for x in 0..5 | |
end | |
end | |
end |
This file contains 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
# jruby-1.7.19 | |
chris@luna /var/www/repos $ ruby bench.rb | |
Calculating ------------------------------------- | |
times 116.501k i/100ms | |
range iteration 125.917k i/100ms | |
upto 132.437k i/100ms | |
for 146.393k i/100ms | |
------------------------------------------------- | |
times 2.933M (± 4.5%) i/s - 14.679M | |
range iteration 2.883M (± 6.5%) i/s - 14.355M | |
upto 2.817M (± 5.4%) i/s - 14.038M | |
for 3.943M (± 6.1%) i/s - 19.617M | |
# jruby-head | |
chris@luna /var/www/repos $ ruby bench.rb | |
Calculating ------------------------------------- | |
times 84.885k i/100ms | |
range iteration 99.954k i/100ms | |
upto 96.530k i/100ms | |
for 92.034k i/100ms | |
------------------------------------------------- | |
times 2.685M (± 4.6%) i/s - 13.412M | |
range iteration 2.581M (± 5.3%) i/s - 12.894M | |
upto 2.767M (± 4.7%) i/s - 13.804M | |
for 2.219M (± 2.8%) i/s - 11.136M |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment