From e1fa3ace8d7fe942a8ed3e5251d9573d3c7638b5 Mon Sep 17 00:00:00 2001 From: xfocus3 Date: Mon, 1 Jun 2026 15:49:59 +0100 Subject: [PATCH] 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 3543214..c780919 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,20 @@ option: hyperfine -L compiler g++,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 `sh` on Unix (resolved through `PATH`) or `cmd.exe` on Windows.