in reply to Re (tilly) 5: how do I line-wrap while copying to stdout?
in thread how do I line-wrap while copying to stdout?

By the undef $/, the file is read in as a huge string. Of course I checked, and with a n=1000 string I get:
Rate regex substr regex 21775/s -- -27% substr 29748/s 37% --
Which makes sense, as my file has some 50k chars.

Jeroen
"We are not alone"(FZ)

Update: (I'm not going to make a Re:{9} post)

I'd say, start checking the source {grin}

$str='a'x1E6; => Rate regex substr regex 15.1/s -- -16% substr 18.0/s 19% -- $str='a'x1E7; => Rate regex substr regex 1.41/s -- -21% substr 1.79/s 27% --
At 100M, I'm testing my swap ;-)..... I tried it nevertheless, but now I'm waiting for my box stop swapping... /me is afraid that may take a while... :-)... finally, I had to use that reboot button :-<
25M still went OK:
s/iter regex substr regex 1.80 -- -21% substr 1.42 27% --
at 50M, benchmark produced a division by zero .....

Replies are listed 'Best First'.
Re (tilly) 8: how do I line-wrap while copying to stdout?
by tilly (Archbishop) on Apr 20, 2001 at 19:20 UTC
    Oops, missed that.

    Still the principle that merlyn stated is correct, and is a common performance mistake in parsing. Try it with a 1 MB string. If substr still wins then I guarantee you that someone implemented a buffering strategy with strings and substr where doing a destructive substr at the beginning of a string just moves indexes around and does not recopy.

    Perl plays a lot of games like that, for instance that is why push, pop and friends are fast. I am just a little surprised to see it played on strings...