Created
October 21, 2010 01:00
-
-
Save phiggins/637708 to your computer and use it in GitHub Desktop.
Stupid benchmark of peach gem
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 'peach' | |
require 'benchmark' | |
def process(n) | |
sleep(1) | |
n**n | |
end | |
n = (ARGV.first || 60).to_i | |
Benchmark.bmbm do |b| | |
b.report("each") do | |
(0..n).to_a.each {|i| process(i) } | |
end | |
b.report("peach") do | |
(0..n).to_a.peach {|i| process(i) } | |
end | |
end | |
#phiggins@gibson:~$ ruby --version | |
#ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] | |
#phiggins@gibson:~$ ruby peach_bench.rb 3 | |
#Rehearsal ----------------------------------------- | |
#each 0.000000 0.010000 0.010000 ( 4.000757) | |
#peach 0.010000 0.000000 0.010000 ( 1.001180) | |
#-------------------------------- total: 0.020000sec | |
# | |
# user system total real | |
#each 0.000000 0.010000 0.010000 ( 4.000728) | |
#peach 0.000000 0.000000 0.000000 ( 1.000630) | |
#phiggins@gibson:~$ ruby peach_bench.rb 30 | |
#Rehearsal ----------------------------------------- | |
#each 0.030000 0.060000 0.090000 ( 31.008580) | |
#peach 0.020000 0.000000 0.020000 ( 1.017262) | |
#-------------------------------- total: 0.110000sec | |
# | |
# user system total real | |
#each 0.020000 0.060000 0.080000 ( 31.004853) | |
#peach 0.010000 0.000000 0.010000 ( 1.002112) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment