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

Benchmark across different branches #606

Open
technicalpickles opened this issue Jan 25, 2023 · 2 comments
Open

Benchmark across different branches #606

technicalpickles opened this issue Jan 25, 2023 · 2 comments

Comments

@technicalpickles
Copy link

When I'm working on performance, I tend to want to compare a baseline from our main branch against my current work. It'd be pretty handy to be able to specify branches at the CLI level to handle the switch. Maybe:

hyperfine --compare-branch main "rails runner true"

You can achieve something similar by including the git checkouts in the command:

$ hyperfine "git switch main; DISABLE_SPRING=1 bin/rails runner true" "git switch performance-improvements; DISABLE_SPRING=1 bin/rails runner true"
Benchmark 1: git checkout main; DISABLE_SPRING=1 bin/rails runner true
  Time (mean ± σ):      8.690 s ±  0.876 s    [User: 4.835 s, System: 4.665 s]
  Range (min … max):    8.114 s … 11.106 s    10 runs

Benchmark 2: git switch performance-improvements; DISABLE_SPRING=1 bin/rails runner true
  Time (mean ± σ):      8.352 s ±  0.363 s    [User: 4.778 s, System: 4.621 s]
  Range (min … max):    7.950 s …  9.020 s    10 runs

Summary
  'git switch performance-improvements; DISABLE_SPRING=1 bin/rails runner true' ran
    1.04 ± 0.11 times faster than 'git checkout main; DISABLE_SPRING=1 bin/rails runner true'
@sharkdp
Copy link
Owner

sharkdp commented Feb 28, 2023

You can do this using a combination of --parameter-list and --setup. Something like the following should work:

hyperfine \
  --parameter-list branch main,performance-improvements \
  --setup "git switch {branch}" \
  "rails runner true"

When I'm working on performance, I tend to want to compare a baseline from our main branch against my current work.

This is indeed a very common use case. We should probably write some documentation for that.

@nirs
Copy link
Contributor

nirs commented Jun 3, 2023

Another way to do this is to use git worktree to have both main/master branch and your work
branch checked out and built and run the benchmark with both. This way you can run benchmarks
with uncommitted changes.

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

No branches or pull requests

3 participants