Skip to content
Myr

Update benchmark results

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Peter · committed by GitHub · parent 814d370 · Browse files · 1 file+27 added−28 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+27 added−28 removed

  • other:+27 added−28 removed

1 file+27 added−28 removed

modified:README.md+27 added-28 removed
28 unmodified lines
2930![Demo](doc/screencast.svg)3132## Benchmark3333Let's search my home folder for files that end in `[0-9].jpg`. It contains ~150.00034Let's search my home folder for files that end in `[0-9].jpg`. It contains ~190.00035subdirectories and about a million files. For averaging and statistical analysis, I'm using35[bench](https://github.com/Gabriel439/bench). All benchmarks are performed for a "warm36cache". Results for a cold cache are similar.36[hyperfine](https://github.com/sharkdp/hyperfine). The following benchmarks are performed37with a "warm"/pre-filled disk-cache (results for a "cold" disk-cache show the same trends).3839Let's start with `find`:40```40find ~ -iregex '.*[0-9]\.jpg$'41Benchmark #1: find ~ -iregex '.*[0-9]\.jpg$'4242time 6.265 s (6.127 s .. NaN s)43 1.000 R² (1.000 R² .. 1.000 R²)44mean 6.162 s (6.140 s .. 6.181 s)45std dev 31.73 ms (0.0 s .. 33.48 ms)43 Time (mean ± σ): 7.236 s ± 0.090 s44 45 Range (min … max): 7.133 s … 7.385 s46```4748`find` is much faster if it does not need to perform a regular-expression search:49```50find ~ -iname '*[0-9].jpg'50Benchmark #2: find ~ -iname '*[0-9].jpg'5152time 2.866 s (2.754 s .. 2.964 s)53 1.000 R² (0.999 R² .. 1.000 R²)54mean 2.860 s (2.834 s .. 2.875 s)55std dev 23.11 ms (0.0 s .. 25.09 ms)52 Time (mean ± σ): 3.914 s ± 0.027 s53 54 Range (min … max): 3.876 s … 3.964 s55```5657Now let's try the same for `fd`. Note that `fd` *always* performs a regular expression58search. The options `--hidden` and `--no-ignore` are needed for a fair comparison,59otherwise `fd` does not have to traverse hidden folders and ignored paths (see below):60```62fd --hidden --no-ignore '.*[0-9]\.jpg$' ~61Benchmark #3: fd -HI '.*[0-9]\.jpg$' ~6264time 892.6 ms (839.0 ms .. 915.4 ms)65 0.999 R² (0.997 R² .. 1.000 R²)66mean 871.2 ms (857.9 ms .. 881.3 ms)67std dev 15.50 ms (0.0 s .. 17.49 ms)63 Time (mean ± σ): 811.6 ms ± 26.9 ms64 65 Range (min … max): 786.0 ms … 870.7 ms66```69For this particular example, `fd` is approximately seven times faster than `find -iregex`70and about three times faster than `find -iname`. By the way, both tools found the exact71same 14030 files :smile:.67For this particular example, `fd` is approximately nine times faster than `find -iregex`68and about five times faster than `find -iname`. By the way, both tools found the exact69same 20880 files :smile:.7071Finally, let's run `fd` without `--hidden` and `--no-ignore` (this can lead to different74search results, of course):72search results, of course). If *fd* does not have to traverse the hidden and git-ignored73folders, it is almost an order of magnitude faster:74```76fd '[0-9]\.jpg$' ~75Benchmark #4: fd '[0-9]\.jpg$' ~7678time 159.5 ms (155.8 ms .. 165.3 ms)79 0.999 R² (0.996 R² .. 1.000 R²)80mean 158.7 ms (156.5 ms .. 161.6 ms)81std dev 3.263 ms (2.401 ms .. 4.298 ms)77 Time (mean ± σ): 123.7 ms ± 6.0 ms78 79 Range (min … max): 118.8 ms … 140.0 ms80```8182**Note**: This is *one particular* benchmark on *one particular* machine. While I have83performed quite a lot of different tests (and found consistent results), things might86be different for you! I encourage everyone to try it out on their own.84be different for you! I encourage everyone to try it out on their own. See 85[this repository](https://github.com/sharkdp/fd-benchmarks) for all necessary scripts.8687Concerning *fd*'s speed, the main credit goes to the `regex` and `ignore` crates that are also used88in [ripgrep](https://github.com/BurntSushi/ripgrep) (check it out!).89
267 unmodified lines