Skip to content

feat: add benchmark for displaying all programs in PATH#5

Open
vegerot wants to merge 1 commit intosharkdp:masterfrom
vegerot:pr5
Open

feat: add benchmark for displaying all programs in PATH#5
vegerot wants to merge 1 commit intosharkdp:masterfrom
vegerot:pr5

Conversation

@vegerot
Copy link

@vegerot vegerot commented Sep 11, 2024

Summary:
This is the first regression we've seen for fd vs. find.

$ PATH="/opt/homebrew/Cellar/findutils/4.10.0/libexec/gnubin/:$PATH" ./warm-cache-exe-paths.sh
Benchmark 1: FIND_PROG=find FIND_ARGS='-maxdepth 1 -executable -type f,l -printf %f\n' get_programs_in_path
  Time (mean ± σ):     142.0 ms ±   6.0 ms    [User: 32.7 ms, System: 72.0 ms]
  Range (min … max):   129.7 ms … 154.6 ms    20 runs

Benchmark 2: FIND_PROG='fd .' FIND_ARGS='--hidden --max-depth=1 --type=executable --follow --format {/} ' get_programs_in_path
  Time (mean ± σ):     272.1 ms ±   6.0 ms    [User: 88.8 ms, System: 142.1 ms]
  Range (min … max):   258.2 ms … 279.9 ms    10 runs

Summary
  FIND_PROG=find FIND_ARGS='-maxdepth 1 -executable -type f,l -printf %f\n' get_programs_in_path ran
    1.92 ± 0.09 times faster than FIND_PROG='fd .' FIND_ARGS='--hidden --max-depth=1 --type=executable --follow --format {/} ' get_programs_in_path
Both fd and find found the same 2943 results

@vegerot
Copy link
Author

vegerot commented Sep 11, 2024

The commit description was measured on macOS. On my GNU+Linux machine it's closer to 7x slower

$ ./warm-cache-exe-paths.sh
Benchmark 1: FIND_PROG='find -L' FIND_ARGS='-maxdepth 1 -executable -type f,l -printf %f\n' get_programs_in_path
  Time (mean ± σ):      40.6 ms ±   0.5 ms    [User: 20.5 ms, System: 24.7 ms]
  Range (min … max):    39.4 ms …  42.1 ms    71 runs

Benchmark 2: FIND_PROG='fd .' FIND_ARGS='--hidden --max-depth=1 --type=executable --follow --format {/} ' get_programs_in_path
  Time (mean ± σ):     281.2 ms ±   4.3 ms    [User: 54.0 ms, System: 397.8 ms]
  Range (min … max):   276.5 ms … 288.7 ms    10 runs

Summary
  FIND_PROG='find -L' FIND_ARGS='-maxdepth 1 -executable -type f,l -printf %f\n' get_programs_in_path ran
    6.93 ± 0.13 times faster than FIND_PROG='fd .' FIND_ARGS='--hidden --max-depth=1 --type=executable --follow --format {/} ' get_programs_in_path
Both fd and find found the same 3806 results

Summary:
This is the first regression we've seen for `fd` vs. `find`.


```sh
$ PATH="/opt/homebrew/Cellar/findutils/4.10.0/libexec/gnubin/:$PATH" ./warm-cache-exe-paths.sh
Benchmark 1: FIND_PROG=find FIND_ARGS='-maxdepth 1 -executable -type f,l -printf %f\n' get_programs_in_path
  Time (mean ± σ):     142.0 ms ±   6.0 ms    [User: 32.7 ms, System: 72.0 ms]
  Range (min … max):   129.7 ms … 154.6 ms    20 runs

Benchmark 2: FIND_PROG='fd .' FIND_ARGS='--hidden --max-depth=1 --type=executable --follow --format {/} ' get_programs_in_path
  Time (mean ± σ):     272.1 ms ±   6.0 ms    [User: 88.8 ms, System: 142.1 ms]
  Range (min … max):   258.2 ms … 279.9 ms    10 runs

Summary
  FIND_PROG=find FIND_ARGS='-maxdepth 1 -executable -type f,l -printf %f\n' get_programs_in_path ran
    1.92 ± 0.09 times faster than FIND_PROG='fd .' FIND_ARGS='--hidden --max-depth=1 --type=executable --follow --format {/} ' get_programs_in_path
Both fd and find found the same 2943 results
```
@tavianator
Copy link

See sharkdp/fd#1614 (comment) and below for some analysis. I don't think this benchmark is useful as-is, but it may be interesting to add benchmarks for wide, shallow directories as well as empty directories to measure startup overhead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants