BurntSushi / walkdir

Rust library for walking directories recursively.
The Unlicense
1.21k stars 106 forks source link

example replaced by walkdir-list, but README not updated #152

Open afontenot opened 3 years ago

afontenot commented 3 years ago

In https://github.com/BurntSushi/walkdir/commit/526d70b165d902b2749fffd6f50d13c1c5ed87e1 the example was replaced by the walkdir-list crate, but the README still references this old example:

# Compile and test speed of `walkdir` crate:
cargo build --release --example walkdir
time ./target/release/examples/walkdir $DIR
afontenot commented 3 years ago

Incidentally, I wonder if you have some idea why walkdir might be so much faster than nftw on my system. I discovered this while writing my own code using them, but I found that it's easily replicable with your example programs:

$ ./target/release/walkdir-list -tcq /usr
739824
duration: 845.646209ms

In nftw.c, I removed the printf call and built it with gcc -O3.

$ time ./nftw /usr
./nftw /usr  0.33s user 1.52s system 99% cpu 1.869 total

Walkdir is faster than find for me as well.

Edit: using strace, it looks like the difference is probably that nftw calls stat on every file in the tree, whereas walkdir does not (presumably only calling stat when needed). If that's what's happening here, may be worth mentioning that in the README?