Re: [PATCH] Use perl instead of tac
- From
- Jörg Sommer <joerg@alea.gnuu.de>
- Date
- Apr 28, 2008, 15:15 UTC
- Message-ID
- <slrng1bqhb.25r.joerg@alea.gnuu.de>
- In-Reply-To
- <86k5iib0g9.fsf@blue.stonehenge.com>
Hallo Randal,
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
Show 7 quoted lines
>>>>>> "Jörg" == Jörg Sommer <joerg@alea.gnuu.de> writes: > > Jörg> What about using a shell function and a *big* variable or an intermediate > Jörg> file? > > What makes you think that's any more faster or efficient than calling Perl > at this point?
Nothing. My intention was not the speed, but the dependency on Perl. But your are right. Except from the point that my suggestion is broken, it's *much* slower:
% time dash -c 'while IFS= read -r line; do rev="$line $rev"; done; printf "%s" "$rev"' < gitk-git/gitk-wish DN dash -c < gitk-git/gitk-wish > /dev/null 2> /dev/null 17,89s user 2,68s system 96% cpu 21,352 total
% time tac < gitk-git/gitk-wish DN tac < gitk-git/gitk-wish > /dev/null 2> /dev/null 0,01s user 0,01s system 91% cpu 0,017 total
% time perl -e 'print reverse <>' < gitk-git/gitk-wish DN perl -e 'print reverse <>' < gitk-git/gitk-wish > /dev/null 2> /dev/null 0,07s user 0,01s system 59% cpu 0,141 total
But I doubt this hurts, because we don't have such a big input.
% wc -l git.c 390 git.c
% time dash -c 'while IFS= read -r line; do rev="$line $rev"; done; printf "%s" "$rev"' < git.c DN dash -c < git.c > /dev/null 2> /dev/null 0,04s user 0,04s system 62% cpu 0,115 total
And what about something like this: 'tac || rev || perl …'
Bye, Jörg.
--
Was der Bauer nicht kennt, das frisst er nicht. Würde der Städter kennen,
was er frisst, er würde umgehend Bauer werden.
Oliver Hassencamp