Skip to content

Commit

Permalink
Microbenchmarks script (#3151)
Browse files Browse the repository at this point in the history
* first iteration of microbenchmarks-compare.sh

Signed-off-by: Francesco Guardiani <[email protected]>

* output the dir

Signed-off-by: Francesco Guardiani <[email protected]>

* Modules off while installing benchstat

Signed-off-by: Francesco Guardiani <[email protected]>

* fix

Signed-off-by: Francesco Guardiani <[email protected]>

* fix

Signed-off-by: Francesco Guardiani <[email protected]>

* Suggestions

Signed-off-by: Francesco Guardiani <[email protected]>
  • Loading branch information
slinkydeveloper authored Jun 4, 2020
1 parent 1f1cd6e commit 0292e17
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/microbenchmarks-compare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

if [ "$1" == "" ] || [ $# -gt 1 ]; then
echo "Error: Expecting an argument" >&2
echo "usage: $(basename $0) revision_to_compare" >&2
exit 1
fi

GO111MODULE=off go get golang.org/x/perf/cmd/benchstat

REVISION="$1"
OUTPUT_DIR=${ARTIFACTS:-$(mktemp -d)}

echo "Outputs will be at $OUTPUT_DIR"

$(dirname $0)/microbenchmarks-run.sh "$OUTPUT_DIR/new.txt"

git checkout "$REVISION"

$(dirname $0)/microbenchmarks-run.sh "$OUTPUT_DIR/old.txt"

benchstat -html "$OUTPUT_DIR/old.txt" "$OUTPUT_DIR/new.txt" >> "$OUTPUT_DIR/results.html"
15 changes: 15 additions & 0 deletions test/microbenchmarks-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

cd "$(dirname $0)/.." || exit

if [ "$1" != "" ]; then
OUTPUT_FILE="$1"
else
OUTPUT_FILE="${ARTIFACTS:-$(mktemp -d)}/bench-result.txt"
fi

echo "Output will be at $OUTPUT_FILE"

go clean
go test -bench=. -benchmem -run="^$" -v ./... >> "$OUTPUT_FILE" || exit

0 comments on commit 0292e17

Please sign in to comment.