James Edward Gray II wrote: > On Mar 13, 2004, at 1:09 PM, R. Joseph Newton wrote: > > > "West, William M" wrote: > > > > > >> by slurping the WHOLE file into memory at once (do you have room to > >> but a 45 > >> megabyte file into memory?) the speed of the processing went up- > > > > Highly unlikely. There is no real speed advantage with Perl in > > slurping a > > file. > > Slurping certainly can be faster. I agree that it's not for > everything, but it certainly has it's place. > > There's and excellent article on perl.com about this: > > http://www.perl.com/pub/a/2003/11/21/slurp.html > > James
Thanks, James, I retested with a case similar to the first example cited in the article, and found that this was indeed the case. This certainly corresponds more closely to what intuition would indicate. About a year ago, though, when I was arguing the converse, the tests that I did showed very little speed advantage from slurping. The results may have been clouded by using the plain old CORE::time function and doing repeated opens of smallish files to get times sufficient to test with. The current tests used a moderately substantial text file--330 KB, and Time::HiRes, and showed an increase of more than 90% in processing time with line-by-line input. I will have to give some thought to the implications of this for programming practice. They probably will not be great. The actual time diference on this half-meg file was still only 4/100s of a second. By the time a file gets large enough that the time difference would get noticable, the file is probably also large enough to put a tax on memory resources for those who don't have 2 GB of RAM at their disposal. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>