-
Notifications
You must be signed in to change notification settings - Fork 20
/
bench.sh
94 lines (64 loc) · 1.93 KB
/
bench.sh
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
###
### Connects to the sever given by -s via ssh, clones the btrblocks repo and builds and executes the benchmark.
### Gets the resulting json file and computes average compression ratio and ratio weighted by column size.
###
HELP="Specify server via -s flag"
TMP_FOLDER="tmp"
TMP_FILE="./${TMP_FOLDER}/result.json"
while getopts "h:s:f:" flag; do
case $flag in
h)
echo "${HELP}"
;;
s)
SERVER=$OPTARG
;;
f)
PREFIX_FLAG="--benchmark_filter=$OPTARG"
;;
\?)
echo "Unknown flag"
;;
esac
done
if ! [ -z "$SERVER" ]
then
ssh $SERVER << EOF
# Prep directories
mkdir -p btr_bench
cd btr_bench
mkdir -p bench_results
# Clone git repo if necessary
if ! [ -d "btrblocks" ]
then
git clone https://github.com/seb711/btrblocks.git
fi
cd btrblocks
# Get newest version and build
git pull
mkdir -p build_release
cd build_release
cmake -DCMAKE_BUILD_TYPE=Release ..
make bench_dataset_downloader
./bench_dataset_downloader
make benchmarks
# Execute benchmarks
./benchmarks --benchmark_out="./../../bench_results/result.json" --benchmark_out_format=json ${PREFIX_FLAG}
# Download result and exit
exit
EOF
if ! [ -d "${TMP_FOLDER}" ]
then
mkdir ${TMP_FOLDER}
fi
scp "${SERVER}:~/btr_bench/bench_results/result.json" ${TMP_FILE}
COMP_RATIO_AVG=$(jq '.benchmarks | map( .comp_ratio_avg ) | add/length' ${TMP_FILE})
UNCOMPRESSED_SIZE=$(jq '.benchmarks | map( .uncompressed_data_size ) | add' ${TMP_FILE})
COMPRESSED_SIZE=$(jq '.benchmarks | map ( .compressed_data_size ) | add' ${TMP_FILE})
WEIGHTED_COMP_RATIO_AVG=$(bc <<< "${UNCOMPRESSED_SIZE} * 1.00/ ${COMPRESSED_SIZE}")
touch bench_result.json
BENCHMARK_MAPPING='.benchmarks | map ( . + { most_used_root_scheme: .label } ) | del ( .[].label )'
jq '{ weighted_comp_ratio_avg: "'$WEIGHTED_COMP_RATIO_AVG'", compression_ratio_average: "'$COMP_RATIO_AVG'", context: .context, benchmarks: ('$BENCHMARK_MAPPING') }' ${TMP_FILE} > bench_result.json
rm ${TMP_FILE}
echo "${HELP}"
fi