Do you know where your variables are? | |
PerlMonks |
Re^2: Reading a huge input line in partsby aaron_baugher (Curate) |
on May 04, 2015 at 23:54 UTC ( [id://1125647]=note: print w/replies, xml ) | Need Help?? |
The performance on that may not be as bad as you think. I tried benchmarking my read-by-chunks solution against a change-the-input-record-separator-to-space solution. The latter makes the code much simpler, since the only special thing you have to watch for is the newlines. But it was also a bit quicker:
The larger the buffer you can use on the read_buffer solution, the faster it should be, I think, but I don't know if it would ever catch up to the $/=' ' solution. Considering how much clearer that one's code is, I think it wins. EDIT: It also occurs to me that reading the file from disc might make a difference, if the RS=space solution causes more disc reads. I'd think OS buffering would prevent that, but I don't know for sure. You'd want to benchmark that with your actual situation. Aaron B.
In Section
Seekers of Perl Wisdom
|
|