On Fri, Nov 07, 2003 at 09:02:23AM -0800, Professional Software Engineering
wrote:
At 10:21 2003-11-07 -0500, Jake Di Toro wrote:
Asked I might have said the same thing... but:
ls -l `which sed` `which tr`
-rwxr-xr-x 1 root root 21132 Jul 4 2001 /bin/sed*
-rwxr-xr-x 1 root root 24056 Jul 12 09:54 /usr/bin/tr*
But again, these are your tools... unless you want to write a quicke
perl script, but that's even more overhead.
<snip>
Since tr doesn't perform regexp operations, I would fully expect it to
parse much quicker, but the difference is going to be negligible on
something so trivial. If you were processing a large file, it'd be a
different matter.
<snip>
to compile:
cc -O3 -o dotdash dotdash.c
strip dotdash
to use:
LISTNAME=`dotdash $LISTNAME`
So just for fun I ran some benchmarks:
Benchmark: timing 1000 iterations of sub_dotdash, sub_sed, sub_tr...
sub_dotdash: 6 wallclock secs ( 0.14 usr 0.16 sys + 0.33 cusr 3.94 csys =
0.00 CPU)
sub_sed: 9 wallclock secs ( 0.13 usr 0.18 sys + 0.60 cusr 5.89 csys =
0.00 CPU)
sub_tr: 9 wallclock secs ( 0.16 usr 0.16 sys + 0.43 cusr 5.54 csys =
0.00 CPU)
and:
Benchmark: timing 10000 iterations of sub_dotdash, sub_sed, sub_tr...
sub_dotdash: 63 wallclock secs ( 1.26 usr 1.80 sys + 3.20 cusr 39.83 csys =
0.00 CPU)
sub_sed: 94 wallclock secs ( 1.24 usr 1.88 sys + 6.33 cusr 58.73 csys =
0.00 CPU)
sub_tr: 86 wallclock secs ( 1.41 usr 1.76 sys + 4.45 cusr 55.25 csys =
0.00 CPU)
As Sean predicted, sed and tr are roughly the same (it takes a lot of
iterations to bring out the difference). dotdash, naturally, blew by
them both.
Scott
--
Scott Wiersdorf
scott(_at_)perlcode(_dot_)org
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail