Instantly share code, notes, and snippets.

Embed
What would you like to do?
test perf between patched and unpatched go encoding/binary
#!/bin/bash
echo "Testing Original"
cp binary_orig.go.old binary.go
for i in {1..5}; do
go test -v -bench='[de]Ints' -run none | grep Read | tee /tmp/tmp.txt
done
echo "Original read ns/op average: $(tr -s ' ' < /tmp/tmp.txt | cut -d' ' -f3 | numaverage)"
echo "Testing Fixed"
cp fixed_binary.go.old binary.go
for i in {1..5}; do
go test -v -bench='[de]Ints' -run none | grep Read | tee /tmp/tmp.txt
done
echo "Fixed read ns/op average: $(tr -s ' ' < /tmp/tmp.txt | cut -d' ' -f3 | numaverage)"
rm /tmp/tmp.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment