3 ms·
In my experience, Perl outperforms sed on most equivalent commands. I should do some benchmarking and add it to the documentation.
by bihla 8y ago
In my experience, Perl outperforms sed on most equivalent commands. I should do some benchmarking and add it to the documentation.
- asicsp 8y agothat would depend on a lot of factors sed provides only BRE/ERE which has lot less features than perl, however in my experience speed is better with BRE/ERE than PCRE, except patterns with backreferences. see also [1] a simple example: $ time sed 's/at/AT/g' /usr/share/dict/words > /dev/null real 0m0.041s user 0m0.037s sys 0m0.004s $ time perl -pe 's/at/AT/g' /usr/share/dict/words > /dev/null real 0m0.056s user 0m0.051s sys 0m0.004s $ time LC_ALL=C sed -nE '/^([a-z]..)\1$/p' /usr/share/dict/words > /dev/null real 0m0.049s user 0m0.048s sys 0m0.000s $ time perl -ne 'print if /^([a-z]..)\1$/' /usr/share/dict/words > /dev/null real 0m0.041s user 0m0.033s sys 0m0.007s [1] https://swtch.com/~rsc/regexp/regexp1.html https://swtch.com/~rsc/regexp/regexp1.html
- rurban 8y agoYou should really use psed then, which came with perl5 from 5.002 until v5.21.1 and is now on CPAN. This is a proper sed, implemented in perl. https://metacpan.org/pod/release/RJBS/perl-5.21.0/x2p/s2p.PL https://metacpan.org/pod/release/RJBS/perl-5.21.0/x2p/s2p.PL https://metacpan.org/pod/release/LEONT/App-s2p-1.000/script/s2p https://metacpan.org/pod/release/LEONT/App-s2p-1.000/script/...