/usr/local/bin/bin/rubycyg -I.. ../benchmark/run.rb ruby 1.9.0 i386-cygwin(2004-09-01) YARVCore Ver.0.0.0.e [direct threaded code] [optimize basic operation] [optimize regexp match] ----------------------------------------------------------- block: class Array def each_ len = self.length i = 0 while i 1) n * fact(n-1) else 1 end end fact(7300) -- user system total real ruby 1.532000 0.040000 1.572000 ( 1.579000) yarv 0.962000 0.120000 1.082000 ( 4.824000) ----------------------------------------------------------- fib: def fib n if n < 3 1 else fib(n-1) + fib(n-2) end end fib(32) -- user system total real ruby 16.083000 0.020000 16.103000 ( 16.588000) yarv 3.305000 0.000000 3.305000 ( 3.439000) ----------------------------------------------------------- lists: #from http://www.bagley.org/~doug/shootout/bench/lists/lists.ruby NUM = 100 SIZE = 10000 def test_lists() # create a list of integers (Li1) from 1 to SIZE li1 = (1..SIZE).to_a # copy the list to li2 (not by individual items) li2 = li1.dup # remove each individual item from left side of li2 and # append to right side of li3 (preserving order) li3 = Array.new while (not li2.empty?) li3.push(li2.shift) end # li2 must now be empty # remove each individual item from right side of li3 and # append to right side of li2 (reversing list) while (not li3.empty?) li2.push(li3.pop) end # li3 must now be empty # reverse li1 in place li1.reverse! # check that first item is now SIZE if li1[0] != SIZE then p "not SIZE" 0 else # compare li1 and li2 for equality if li1 != li2 then return(0) else # return the length of the list li1.length end end end i = 0 while i 1 1 + reccount(n-1) else 1 end end reccount 7000 -- user system total real ruby 0.090000 0.040000 0.130000 ( 4.822000) yarv 0.010000 0.000000 0.010000 ( 0.668000) ----------------------------------------------------------- regexp: i=0 while i<1000000 /hoge/ =~ 'xxxhogexxx' i+=1 end -- user system total real ruby 5.458000 0.010000 5.468000 ( 5.622000) yarv 3.264000 0.000000 3.264000 ( 3.323000) ----------------------------------------------------------- rescue: i=0 while i<1000000 i+=1 begin begin rescue end rescue # ensure end end -- user system total real ruby 2.924000 0.010000 2.934000 ( 2.988000) yarv 0.481000 0.000000 0.481000 ( 0.481000) ----------------------------------------------------------- sieve: # from http://www.bagley.org/~doug/shootout/bench/sieve/sieve.ruby num = 100 count = i = j = 0 flags0 = Array.new(8192,1) k = 0 while k < num k+=1 count = 0 flags = flags0.dup i = 2 while i<8192 i+=1 if flags[i] # remove all multiples of prime: i j = i*i while j < 8192 j += i flags[j] = nil end count += 1 end end end count -- user system total real ruby 9.233000 0.010000 9.243000 ( 9.389000) yarv 2.774000 0.010000 2.784000 ( 2.830000) ----------------------------------------------------------- simplereturn: def m return 1 end i=0 while i<1000000 i+=1 m end -- user system total real ruby 3.155000 0.010000 3.165000 ( 3.214000) yarv 0.931000 0.010000 0.941000 ( 0.961000) ----------------------------------------------------------- strconcat: i=0 while i<1000000 "#{1+1} #{1+1} #{1+1}" i+=1 end -- user system total real ruby 26.759000 0.000000 26.759000 ( 27.104000) yarv 23.514000 0.000000 23.514000 ( 24.035000) ----------------------------------------------------------- tak: def tak x, y, z unless y < x z else tak( tak(x-1, y, z), tak(y-1, z, x), tak(z-1, x, y)) end end tak(18, 9, 0) -- user system total real ruby 51.784000 0.000000 51.784000 ( 52.947000) yarv 12.258000 0.000000 12.258000 ( 12.580000) ----------------------------------------------------------- tarai: def tarai( x, y, z ) if x <= y then y else tarai(tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y)) end end tarai(12, 6, 0) -- user system total real ruby 41.740000 0.020000 41.760000 ( 42.619000) yarv 12.388000 0.010000 12.398000 ( 12.619000) ----------------------------------------------------------- temp: i=0 while i<1000000 i+=1 begin begin rescue end rescue ensure end end -- user system total real ruby 3.394000 0.000000 3.394000 ( 3.421000) yarv 0.461000 0.000000 0.461000 ( 0.493000) ----------------------------------------------------------- whileloop: i = 0 while(i<1000000) i+=1 end -- user system total real ruby 1.923000 0.010000 1.933000 ( 1.931000) yarv 0.410000 0.000000 0.410000 ( 0.419000)