From: "Gerardo Santana Gómez Garrido" Date: 2008-03-20T01:44:11+09:00 Subject: Re: Ruby "Speedup" hints? On 3/19/08, Paul Brannan wrote: > On Tue, Mar 18, 2008 at 02:40:43PM +0900, Gerardo Santana G?mez Garrido wrote: > > $ time ruby a.rb 10_000_000 > /tmp/a && sleep 3 && time ruby b.rb > > 10_000_000 > /tmp/b; printf "\a" > > > > real 1m45.305s > > user 1m27.581s > > sys 0m17.715s > > > > real 0m59.049s > > user 0m41.984s > > sys 0m16.997s > > $ cat a.rb > > times = ARGV[0].to_i > > times.times { puts "hola mundo" } > > $ cat b.rb > > require 'stringio' > > > > times = ARGV[0].to_i > > output = StringIO.new > > times.times { output.write("hola mundo\n") } > > output.rewind > > print output.read > > > I think you are demonstrating the difference between IO#puts and > IO#write (which still surprised me). Replace output.write("hola mundo\n") with output.puts("hola mundo") and you'll get something similar. -- Gerardo Santana