https://github.com/canop/walk_pace
A simple evaluation of the cost of using rust's standard WalkDir
https://github.com/canop/walk_pace
Last synced: 3 months ago
JSON representation
A simple evaluation of the cost of using rust's standard WalkDir
- Host: GitHub
- URL: https://github.com/canop/walk_pace
- Owner: Canop
- Created: 2019-01-11T17:17:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-13T12:13:44.000Z (over 7 years ago)
- Last Synced: 2025-12-26T20:57:48.868Z (7 months ago)
- Language: Rust
- Size: 4.88 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
The de facto standard [walkdir](https://github.com/BurntSushi/walkdir) crate offers a very configurable way to walk over the files of a directory.
But this power comes with a cost.
After having improved the performances of computing directory size in [broot](https://github.com/Canop/broot) by 15% by removing walkdir, I wanted to have a clearer idea of the cost, which is why I wrote this simple bench comparing walkdir with a naive and obvious implementation for some very simple operations.
Here's the output on my computer:
dys@dys-desktop:~/dev/walk_pace> target/release/walk_pace
warming up
count_files_walking. Number of files: 1685126
count_files_running. Number of files: 1685113
count_visible_files_walking. Number of files: 1225536
count_visible_files_running. Number of files: 1225523
measuring
counting files, walking, took 2.027986542s
counting files, running, took 1.77173462s
counting visible files, walking, took 1.481694735s
counting visible files, running, took 1.27163876s
(the files listed by walkdir and not by my iteration are in `/proc`)
In all my tests I get about the same result of 15% overhead of WalkDir over a simple iteration, be it DFS, BFS, or mixed.
And here are my personal conclusions:
* WalkDir does allow for a much shorter and clearer code
* WalkDir isn't *that* slow
* WalkDir might be a poor choice when performances matter and the operation involves dealing with a lot of files