Adding to the front of a line
Florian Diesch
diesch at spamfence.net
Wed Jan 21 19:39:54 UTC 2009
David Fox <dfox94085 at gmail.com> wrote:
> On Tue, Jan 20, 2009 at 10:43 PM, Matthew Flaschen
> <matthew.flaschen at gatech.edu> wrote:
>> In other words, the sequence is used as input, but not timed.
>
> I see. Well, in that case, the difference between using a while read
> vs a sed is dramatic:
>
> dfox at ubuntu:~$ time (while read lines; do echo "127.0.0.1 " $lines;
> done) <lines >newlines
>
> real 0m37.781s
> user 0m29.542s
> sys 0m7.732s
I didn't expect bash beeing *that* much slower than sh:
diesch at scenic:~% time sh -c 'seq 1 1000000 | while read site; do echo "127.0.0.1 $site"; done > /dev/null'
sh -c 7,84s user 6,28s system 84% cpu 16,776 total
diesch at scenic:~% time bash -c 'seq 1 1000000 | while read site; do echo "127.0.0.1 $site"; done > /dev/null'
bash -c 59,87s user 7,73s system 82% cpu 1:22,21 total
Florian
--
<http://www.florian-diesch.de/>
-----------------------------------------------------------------------
** Hi! I'm a signature virus! Copy me into your signature, please! **
-----------------------------------------------------------------------
More information about the ubuntu-users
mailing list