diff-benchmarks.sh 642 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#!/bin/bash

before="$1"
after="$2"

parse() {
    sed -n \
        -e 's/ *\t */\t/g' \
        -e '/^Benchmark/p' |
        column -s'	' --json \
               --table-columns name,count,time,rate \
               --table-name "results" |
        jq '.results[] | {name: .name, time: (.time | rtrimstr(" ns/op") | tonumber)}'
}

benchcmp "$1" "$2"

echo ""
echo "Result:"

{
    parse < "$1"
    parse < "$2"
} | jq -e -r -s 'group_by(.name)[] | {name: .[0].name, speedup: (.[1].time / .[0].time)} | select(.speedup < 0.90) | "\(.name)\t\(.speedup)x"'

if [[ $? -ne 4 ]]; then
    echo ""
    echo "FAIL"
    exit 1
else
    echo "PASS"
fi