yarv-dev:232
From: SASADA Koichi <ko1 atdot.net>
Date: Wed, 29 Sep 2004 10:53:49 +0900
Subject: [yarv-dev:232] Re: fixed stack frame designe
SASADA Koichi <ko1 atdot.net> Wed, 29 Sep 2004 03:38:08 +0900 / [yarv-dev:231] fixed stack frame designe ささだです。 もう一個。 -- // SASADA Koichi at atdot dot net // /usr/local/bin/ruby_cyg19 -I.. ../benchmark/run.rb ruby 1.9.0 i386-cygwin(2004-09-12) 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<len a = self[i] yield a i+=1 end end end (1..100000).to_a.each_{|e|} -- user system total real ruby 0.188000 0.000000 0.188000 ( 0.189000) yarv 0.078000 0.000000 0.078000 ( 0.078000) ----------------------------------------------------------- const: i = 0 Const = 1 while i < 1000000 i+= Const end -- user system total real ruby 0.750000 0.000000 0.750000 ( 0.750000) yarv 0.171000 0.000000 0.171000 ( 0.170000) ----------------------------------------------------------- ensure: i=0 while i<100000 i+=1 begin begin ensure end ensure end end -- user system total real ruby 0.094000 0.000000 0.094000 ( 0.106000) yarv 0.031000 0.000000 0.031000 ( 0.018000) ----------------------------------------------------------- factorial: def fact(n) if(n > 1) n * fact(n-1) else 1 end end fact(7300) -- user system total real ruby 0.688000 0.047000 0.735000 ( 0.740000) yarv 0.500000 0.016000 0.516000 ( 0.509000) ----------------------------------------------------------- fib: def fib n if n < 3 1 else fib(n-1) + fib(n-2) end end fib(32) -- user system total real ruby 5.625000 0.000000 5.625000 ( 5.650000) yarv 1.109000 0.000000 1.109000 ( 1.109000) ----------------------------------------------------------- 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<NUM i+=1 result = test_lists() end result -- user system total real ruby 2.937000 0.000000 2.937000 ( 2.951000) yarv 2.063000 0.000000 2.063000 ( 2.067000) ----------------------------------------------------------- reccount: def reccount n if n > 1 1 + reccount(n-1) else 1 end end reccount 7000 -- user system total real ruby 0.062000 0.000000 0.062000 ( 0.073000) yarv 0.000000 0.000000 0.000000 ( 0.006000) ----------------------------------------------------------- regexp: i=0 while i<1000000 /hoge/ =~ 'xxxhogexxx' i+=1 end -- user system total real ruby 2.031000 0.000000 2.031000 ( 2.028000) yarv 1.282000 0.000000 1.282000 ( 1.283000) ----------------------------------------------------------- rescue: i=0 while i<100000 i+=1 begin begin rescue end rescue end end -- user system total real ruby 0.109000 0.000000 0.109000 ( 0.107000) yarv 0.016000 0.000000 0.016000 ( 0.018000) ----------------------------------------------------------- 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 3.125000 0.000000 3.125000 ( 3.117000) yarv 0.984000 0.015000 0.999000 ( 1.002000) ----------------------------------------------------------- simplereturn: def m return 1 end i=0 while i<1000000 i+=1 m end -- user system total real ruby 1.109000 0.000000 1.109000 ( 1.112000) yarv 0.313000 0.000000 0.313000 ( 0.317000) ----------------------------------------------------------- strconcat: i=0 while i<1000000 "#{1+1} #{1+1} #{1+1}" i+=1 end -- user system total real ruby 10.594000 0.000000 10.594000 ( 10.655000) yarv 9.875000 0.000000 9.875000 ( 9.921000) ----------------------------------------------------------- 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 18.156000 0.000000 18.156000 ( 18.175000) yarv 4.313000 0.000000 4.313000 ( 4.313000) ----------------------------------------------------------- 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 14.594000 0.000000 14.594000 ( 14.602000) yarv 4.406000 0.000000 4.406000 ( 4.412000) ----------------------------------------------------------- whileloop: i = 0 while(i<1000000) i+=1 end -- user system total real ruby 0.656000 0.000000 0.656000 ( 0.658000) yarv 0.157000 0.000000 0.157000 ( 0.154000) -- ML: yarv-dev quickml.atdot.net 使い方: http://www.atdot.net/~ko1/quickml
231 2004-09-29 03:38 [ko1 atdot.net ] fixed stack frame designe -> 232 2004-09-29 10:53 ┗[ko1 atdot.net ]