From: jm Date: 2004-12-31T07:26:10+09:00 Subject: Re: seeking hints for fast io I typed this from memory and forgot a line. sout is an array, but I'll try what you've said and see if it helps any as there's no reason for this to be an array instead of a string except for what I read somewhere in the pickaxe book (p369, 2nd ed). Jeff. >> > def to_s sout = Array.new() >> > sout << "a=#{@a}" >> > sout << "b=#{@b}" >> > sout.join("\n") >> > end >> > end >> > >> > # in main >> > File.open(outfile,File::CREAT|File::RDWR|File::APPEND) do |fp| >> > the_data.each do |d| >> > fp.puts d >> > fp.puts # add blank line >> > end >> > end >> > >> > Anyone care to suggest a way to speed this up? Is it faster to >> > >> > sout << "a=" + @a >> > >> > instead of >> > >> > sout << "a=#{@a}" >> >> Probably not, String#+ creates new strings, String#<< appends to an >> existing string > > This is quite simple and avoids the unnecessary string interpolation. > I guess it'll be faster: > > sout << "a=" << @a > > Kind regards > > robert > >