Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up the Tap#formula_files method #18163

Closed

Commits on Aug 25, 2024

  1. Speed up the Tap#formula_files method

    We already know that the directory and files are going to be formula files if they are ruby files
    so that's all we really need to check for here. The other change is to use `File.extname` instead
    of `Pathname#extname` which we assume is faster because it doesn't use the monkey-patched version
    that handles some additional extension types with multiple periods.
    
    ```
    $ hyperfine --parameter-list branch master,speed-up-loading-cask-and-formula-file-names --warmup 5 --setup 'git switch {branch}' 'brew cat gimp'
    Benchmark 1: brew cat gimp (branch = master)
      Time (mean ± σ):      2.109 s ±  0.010 s    [User: 1.349 s, System: 0.726 s]
      Range (min … max):    2.097 s …  2.128 s    10 runs
    
    Benchmark 2: brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names)
      Time (mean ± σ):      1.795 s ±  0.011 s    [User: 1.061 s, System: 0.702 s]
      Range (min … max):    1.777 s …  1.813 s    10 runs
    
    Summary
      brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names) ran
        1.17 ± 0.01 times faster than brew cat gimp (branch = master)
    ```
    apainintheneck committed Aug 25, 2024
    Configuration menu
    Copy the full SHA
    8664972 View commit details
    Browse the repository at this point in the history