From 12882b550a449cb0ca3dbe6c5e3da89e0d6a97e5 Mon Sep 17 00:00:00 2001 From: xfocus3 Date: Mon, 1 Jun 2026 15:49:59 +0100 Subject: [PATCH 1/2] docs: show how to benchmark across git branches --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index ff6020064..0b3fbc68d 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,20 @@ option: hyperfine -L compiler gcc,clang '{compiler} -O2 main.cpp' ``` +A common use case is comparing the same command across multiple Git branches. Use `--setup` +to switch branches once before each set of timing runs, so the branch switch is not part of +the measured command: +```sh +hyperfine \ + --parameter-list branch main,performance-improvements \ + --setup 'git switch {branch}' \ + 'rails runner true' +``` + +Make sure your working tree is clean before switching branches. If you want to benchmark +uncommitted changes, consider using `git worktree` and benchmarking the same command in each +worktree instead. + ### Intermediate shell By default, commands are executed using a predefined shell (`/bin/sh` on Unix, `cmd.exe` on Windows). From b008ba0b518027326e39b18895f45851f03b9c4a Mon Sep 17 00:00:00 2001 From: xfocus3 <211965064+xfocus3@users.noreply.github.com> Date: Mon, 1 Jun 2026 20:43:03 +0100 Subject: [PATCH 2/2] docs: mention branch checkout side effect --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0b3fbc68d..8cbafdee4 100644 --- a/README.md +++ b/README.md @@ -97,9 +97,10 @@ hyperfine \ 'rails runner true' ``` -Make sure your working tree is clean before switching branches. If you want to benchmark -uncommitted changes, consider using `git worktree` and benchmarking the same command in each -worktree instead. +Make sure your working tree is clean before switching branches. Because this `--setup` command +changes the checkout, the repository will remain on the last branch from `--parameter-list` +after the benchmark finishes. If you want to benchmark uncommitted changes, consider using +`git worktree` and benchmarking the same command in each worktree instead. ### Intermediate shell