Created
October 16, 2023 18:17
-
-
Save sholderbach/280a04e80e57948a6d94670dacbd2e6e to your computer and use it in GitHub Desktop.
Minimal commit driven nushell benchmark tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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