On 01/20/2012 11:45 AM, Vincent Lefevre wrote:
sed is inefficient on a regexp starting with "(.*":

$ time sed -n "s/\(.*49026\)/\1/p" ChangeLog
2012-01-12 23:39:18 (rev 49026, vinc17/xvii)
4.62s user 0.00s system 99% cpu 4.637 total

Compare to the equivalent:

$ time sed -n "s/^\(.*49026\)/\1/p" ChangeLog
2012-01-12 23:39:18 (rev 49026, vinc17/xvii)
0.27s user 0.00s system 99% cpu 0.278 total

Please reassign to glibc.

Note that depending on what you are trying to do, you might like these fast alternatives that do not use grouping parentheses:

   time sed -n 's/.*49026/&/p' ChangeLog
   time sed -n '/.*49026/p' ChangeLog

In particular, outside the s/// command the parentheses are ignored, so this is also fast.

   time sed -n '/\(.*49026\)/p' ChangeLog

Paolo



--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to