-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun
executable file
·46 lines (36 loc) · 1.28 KB
/
run
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
#!/usr/bin/env bash
set -Eeuo pipefail
shopt -s nullglob
pushd "$(dirname "$0")" >/dev/null
candidates=('esbuild' 'minify-js')
candidate_output_min_lens=(0 0)
candidate_output_times=(0 0)
inputs=(_input/*)
src_len_sum=0
for input in ${inputs[@]}; do
src_len=$(wc -c < "$PWD/$input")
src_len_sum=$(( src_len_sum + src_len ))
done
for candidate_idx in ${!candidates[@]}; do
candidate=${candidates[$candidate_idx]}
for input in ${inputs[@]}; do
raw=$("./$candidate/run" "$PWD/$input" 10)
res=($raw)
min_len=${res[0]}
time_ns=${res[1]}
candidate_output_min_lens[$candidate_idx]=$(( candidate_output_min_lens[candidate_idx] + min_len ))
candidate_output_times[$candidate_idx]=$(( candidate_output_times[candidate_idx] + time_ns ))
done
done
rm -rf results
mkdir results
for candidate_idx in ${!candidates[@]}; do
candidate=${candidates[$candidate_idx]}
min_len_sum=${candidate_output_min_lens[$candidate_idx]}
avg_min_pct=$(bc -l <<< "($min_len_sum/$src_len_sum) * 100")
echo -e "$candidate_idx\t$candidate\t$avg_min_pct" >> results/average-sizes.txt
time_ns_sum=${candidate_output_times[$candidate_idx]}
time_sec_sum=$(bc -l <<< "$time_ns_sum / 1000000000")
echo -e "$candidate_idx\t$candidate\t$time_sec_sum" >> results/total-times.txt
done
popd >/dev/null