Skip to content

Instantly share code, notes, and snippets.

@sholderbach
Created October 16, 2023 18:17
Show Gist options
  • Save sholderbach/280a04e80e57948a6d94670dacbd2e6e to your computer and use it in GitHub Desktop.
Save sholderbach/280a04e80e57948a6d94670dacbd2e6e to your computer and use it in GitHub Desktop.
Minimal commit driven nushell benchmark tool
#!/usr/bin/env nu
def main [
--depth=1: int # How many commits back to go
script # The benchmark script you want to run
] {
let start_commit = (git rev-parse --short HEAD)
let start_branch = (git branch --show-current)
mut commits = []
for i in ..$depth {
let current = (git rev-parse --short HEAD)
if not ($current | path exists) {
cargo build --release
cp target/release/nu $current
}
$commits ++= $current
git checkout HEAD~1
}
if ($start_branch | is-empty) {
git checkout $start_commit
} else {
git switch $start_branch
}
print $commits
# running in reverse so as to not bias through CPU thermals
for commit in ($commits | reverse ) {
print $"=== ($commit) ==="
try { run-external $"./($commit)" $script }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment