Created
December 18, 2013 21:08
-
-
Save chuckremes/8029858 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' | |
require 'benchmark/ips' | |
require 'date' | |
fi = Date.new(1926,6,1) | |
Count = 5 | |
dates = Count.times.to_a.map { |i| fi + i } | |
Benchmark.ips do |x| | |
x.report "Date#mon " do |times| | |
i = 0 | |
while i < times | |
#(fi + i%2).mon | |
j = 0 | |
while j < Count | |
dates[j].mon | |
j += 1 | |
end | |
i += 1 | |
end | |
end | |
x.report "Date#mon2" do |times| | |
i = 0 | |
while i < times | |
(fi + i%2).mon | |
i += 1 | |
end | |
end | |
x.report "Date#mon3" do |times| | |
i = 0 | |
while i < times | |
(fi + i).mon | |
i += 1 | |
end | |
end | |
x.report "Date#mon4" do |times| | |
i = 0 | |
while i < times | |
fi.mon | |
i += 1 | |
end | |
end | |
x.report "Date#new " do |times| | |
i = 0 | |
while i < times | |
Date.new(1926,6,1) | |
i += 1 | |
end | |
end | |
# | |
# x.report "Date#year" do |times| | |
# i = 0 | |
# while i < times | |
# (fi + i%2).year | |
# i += 1 | |
# end | |
# end | |
x.report "Date#+" do |times| | |
i = 0 | |
while i < times | |
newdate = fi + i | |
i += 1 | |
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
Charless-Mac-Pro:rubinius cremes$ bin/benchmark -trbx -t"jruby --server" -truby2 benchmark/core/date/bench_mon.rb | |
=== bin/rbx === | |
Date#mon 564287.3 (±5.6%) i/s - 2811136 in 5.008319s (cycle=35584) | |
Date#mon2 84906.7 (±3.1%) i/s - 427156 in 5.036177s (cycle=4643) | |
Date#mon3 84892.3 (±1.8%) i/s - 430200 in 5.069337s (cycle=7170) | |
Date#mon4 3748984.2 (±5.3%) i/s - 18699120 in 5.005900s (cycle=155826) | |
Date#new 102422.3 (±6.2%) i/s - 519520 in 5.107136s (cycle=7640) | |
Date#+ 906731.6 (±2.0%) i/s - 4542048 in 5.011255s (cycle=47313) | |
=== jruby --server === | |
Date#mon 604013.6 (±6.0%) i/s - 3006234 in 5.001000s (cycle=30366) | |
Date#mon2 679961.4 (±30.9%) i/s - 2163428 in 5.008999s (cycle=34894) | |
Date#mon3 594166.0 (±39.6%) i/s - 1616972 in 5.405000s (cycle=37604) | |
Date#mon4 4202300.5 (±7.4%) i/s - 20879463 in 5.009000s (cycle=88099) | |
Date#new 760695.3 (±7.5%) i/s - 3783426 in 5.010000s (cycle=20341) | |
Date#+ 705049.0 (±47.5%) i/s - 1421850 in 5.048000s (cycle=56874) | |
=== ruby2 === | |
Date#mon 2180978.7 (±5.2%) i/s - 10894100 in 5.016489s (cycle=55300) | |
Date#mon2 2030388.5 (±19.5%) i/s - 9749500 in 5.013922s (cycle=52700) | |
Date#mon3 2202404.0 (±19.9%) i/s - 10567099 in 5.009852s (cycle=53101) | |
Date#mon4 14567732.5 (±0.9%) i/s - 72806652 in 4.998209s (cycle=75604) | |
Date#new 1670534.8 (±16.5%) i/s - 8113871 in 5.019878s (cycle=42481) | |
Date#+ 2980808.4 (±27.6%) i/s - 13749645 in 5.004015s (cycle=56121) | |
Comparing benchmark/core/date/bench_mon.rb:Date#new : | |
ruby2: 1670534 i/s | |
jruby --server: 760695 i/s - 2.20x slower | |
bin/rbx: 102422 i/s - 16.31x slower | |
Comparing benchmark/core/date/bench_mon.rb:Date#+: | |
ruby2: 2980808 i/s | |
bin/rbx: 906731 i/s - 3.29x slower | |
jruby --server: 705048 i/s - 4.23x slower | |
Comparing benchmark/core/date/bench_mon.rb:Date#mon4: | |
ruby2: 14567732 i/s | |
jruby --server: 4202300 i/s - 3.47x slower | |
bin/rbx: 3748984 i/s - 3.89x slower | |
Comparing benchmark/core/date/bench_mon.rb:Date#mon3: | |
ruby2: 2202404 i/s | |
jruby --server: 594165 i/s - 3.71x slower | |
bin/rbx: 84892 i/s - 25.94x slower | |
Comparing benchmark/core/date/bench_mon.rb:Date#mon2: | |
ruby2: 2030388 i/s | |
jruby --server: 679961 i/s - 2.99x slower | |
bin/rbx: 84906 i/s - 23.91x slower | |
Comparing benchmark/core/date/bench_mon.rb:Date#mon : | |
ruby2: 2180978 i/s | |
jruby --server: 604013 i/s - 3.61x slower | |
bin/rbx: 564287 i/s - 3.87x slower |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment