2021-06-01 19:56:11 +08:00
|
|
|
#!/usr/bin/env bash
|
2021-05-26 21:57:22 +08:00
|
|
|
|
|
|
|
# Requirements:
|
|
|
|
# - critcmp. See: https://github.com/BurntSushi/critcmp
|
2021-06-01 22:37:57 +08:00
|
|
|
# - curl
|
2021-05-26 21:57:22 +08:00
|
|
|
|
|
|
|
# Usage
|
|
|
|
# $ bash compare.sh json_file1 json_file1
|
|
|
|
# ex: bash compare.sh songs_main_09a4321.json songs_geosearch_24ec456.json
|
|
|
|
|
|
|
|
# Checking that critcmp is installed
|
|
|
|
command -v critcmp > /dev/null 2>&1
|
|
|
|
if [[ "$?" -ne 0 ]]; then
|
2021-06-03 21:39:52 +08:00
|
|
|
echo 'You must install critcmp to make this script work.'
|
2021-05-26 21:57:22 +08:00
|
|
|
echo 'See: https://github.com/BurntSushi/critcmp'
|
2021-06-03 21:39:52 +08:00
|
|
|
echo ' $ cargo install critcmp'
|
2021-05-26 21:57:22 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $# -ne 2 ]]
|
|
|
|
then
|
|
|
|
echo 'Need 2 arguments.'
|
|
|
|
echo 'Usage: '
|
2021-06-03 21:39:52 +08:00
|
|
|
echo ' $ ./compare.sh old new'
|
2021-05-26 21:57:22 +08:00
|
|
|
echo 'Ex:'
|
2021-06-02 00:57:35 +08:00
|
|
|
echo ' $ ./compare.sh songs_main_09a4321.json songs_geosearch_24ec456.json'
|
2021-05-26 21:57:22 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-06-03 21:39:52 +08:00
|
|
|
old_file="$1"
|
|
|
|
new_file="$2"
|
2021-06-01 20:43:47 +08:00
|
|
|
s3_url='https://milli-benchmarks.fra1.digitaloceanspaces.com/critcmp_results'
|
2021-05-26 21:57:22 +08:00
|
|
|
|
2021-06-03 21:39:52 +08:00
|
|
|
for file in $old_file $new_file
|
|
|
|
do
|
|
|
|
file_s3_url="$s3_url/$file"
|
|
|
|
file_local_path="/tmp/$file"
|
|
|
|
|
|
|
|
if [[ ! -f $file_local_path ]]; then
|
|
|
|
curl $file_s3_url --output $file_local_path --silent
|
|
|
|
if [[ "$?" -ne 0 ]]; then
|
|
|
|
echo 'curl command failed.'
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-06-01 19:56:42 +08:00
|
|
|
fi
|
2021-06-03 21:39:52 +08:00
|
|
|
done
|
2021-05-26 21:57:22 +08:00
|
|
|
|
2021-06-03 21:39:52 +08:00
|
|
|
# Print the diff changes between the old and new benchmarks
|
|
|
|
# by only displaying the lines that have a diff of more than 5%.
|
|
|
|
critcmp --threshold 5 "/tmp/$old_file" "/tmp/$new_file"
|