Skip to content

Instantly share code, notes, and snippets.

@unfo
Created September 12, 2025 09:10
Show Gist options
  • Select an option

  • Save unfo/3d1299fe808f7296423bf644eba9ca06 to your computer and use it in GitHub Desktop.

Select an option

Save unfo/3d1299fe808f7296423bf644eba9ca06 to your computer and use it in GitHub Desktop.
hyperfine benchmark for finding git root from subdir
pushd . >/dev/null; until [ -d .git ]; do cd ..; pwd; done | tail -n 1; popd -n > /dev/null;
Command Mean [ms] Min [ms] Max [ms] Relative
git rev-parse show root 54.5 ± 38.3 28.8 249.2 1.19 ± 0.98
git !pwd 59.9 ± 46.5 25.1 260.5 1.31 ± 1.16
git !exec pwd 51.4 ± 20.8 25.8 122.4 1.12 ± 0.67
git_root.sh 45.9 ± 20.2 21.4 111.5 1.00

Summary

  git_root.sh ran
    1.12 ± 0.67 times faster than git !exec pwd
    1.19 ± 0.98 times faster than git rev-parse show root
    1.31 ± 1.16 times faster than git !pwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment