Dan rants: Some Unix notes

A comment to Tom Duff about a credit to him in some ancient Unix book for writing the pick utility degenerated into talk about args which lead to xargs and discussion of command line length limits, which lead to an interesting benchmark (If you're a nerdly weenie). On a random Octane in a source tree with 899 .c files:

time "find . -name '*.c' -exec grep abc {} /dev/null \;"

took 29 seconds, whereas:

time sh -c "find . -name '*.c' -print | xargs grep abc"

took 18 seconds. My first response was "wow, all those individual execs were slow" until I timed the first again without the /dev/null (included because I wanted to make sure that grep printed out the full filename) and got 21 seconds. Times are repeatable.

So 889 extra execs of grep take roughly 3 seconds, but 899 opens of /dev/null take 8 seconds. Hmmmm...


Tuesday, December 07th, 1999 danlyke@flutterby.com