[comp.sources.d] v06i041: Findname, script to find filenames fast

pokey@well.UUCP (Jef Poskanzer) (02/26/89)

Geez, talk about re-inventing the square wheel!
---
Jef

vixie@decwrl.dec.com (Paul A Vixie) (02/27/89)

Synopsis:
  "du -a" is not faster than "find . -print", at least on Ultrix.

Explaination:
  there isn't any reason for either to be faster since they both do the same
  thing -- recursively descend a directory hierarchy, doing a stat(2) on each
  name found in each directory.  Note that find has to do a stat(2) on each
  name even if it's only going to print the names, since it has to know
  whether the file is a directory (which would need to be descended into).  I
  ran "find . -print", "du -a", and "ls -lR" in my home directory (which has
  5,326 files in it).  I ran them a few times to make sure the inodes were
  all in the cache.

Detail:
  % time find . -print > /dev/null
  0.4u 3.5s 0:04 100% 70+104k 1+1io 0pf+0w

  % time du -a > /dev/null
  1.3u 3.5s 0:04 103% 13+57k 0+0io 0pf+0w

  % time ls -1R > /dev/null
  2.6u 4.3s 0:06 101% 69+160k 0+4io 0pf+0w
--
Paul Vixie
Work:    vixie@decwrl.dec.com    decwrl!vixie    +1 415 853 6600
Play:    paul@vixie.sf.ca.us     vixie!paul      +1 415 864 7013