Don't understand german? Read or subscribe to my english-only feed.

zsh: zargs

Let me show the power of zargs. First of all let’s see wheter both commands do the same:

$ find /usr/include -name \*.h -exec grep printf /dev/null {} \; | wc -l
389
$ zargs /usr/include/**/*.h -- grep printf /dev/null | wc -l
389

Yes, seems so – so let’s compare them via ‘time’:

$ time ( find /usr/include -name \*.h -exec grep printf /dev/null >| /dev/null {} \; )
Real: 4,89s User: 1,41s System: 3,46s CPU-percent: 99%
$ time ( zargs /usr/include/**/*.h -- grep printf /dev/null >| /dev/null )
Real: 0,27s User: 0,14s System: 0,14s CPU-percent: 102%

4 Responses to “zsh: zargs”

  1. mp Says:

    So if you use zsh on Gentoo will the numbers then decrease again? Looks quite impressive.

  2. mika Says:

    Taking a look at my centericq-history shows me that you’re planning to install Gentoo on your 31337 ‘Acer Travelmate 8004LMi’ notebook. So this might be something for you – yes.

  3. arved Says:

    102% CPU?

  4. mika Says:

    I was using:

    TIMEFMT=”Real: %E User: %U System: %S CPU-percent: %P”

    The CPU percentage is computed as (CPU seconds spent in user mode + CPU seconds spent in kernel mode)/(elapsed time in seconds)

    Now just calculate it with an example:

    $ echo ‘scale=2; (0.14+0.12)/0.25’ | bc -l
    1.04

    For more details refer to the implementation in zsh: in function printtime [lines 535-539] in jobs.c (current zsh-version).