summaryrefslogtreecommitdiff
path: root/util/compress/libdeflate/scripts/produce_gzip_benchmark_table.sh
blob: 03fc927e5b59b049f812eaa8cc9c26072c6f01c9 (plain)
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
#!/bin/bash

set -eu -o pipefail
topdir="$(dirname "$0")/.."

do_benchmark() {
	"$topdir/benchmark" -g -s "$(stat -c %s "$file")" "$@" "$file" \
		| grep Compressed | cut -f 4 -d ' '
}

echo "File | zlib -6 | zlib -9 | libdeflate -6 | libdeflate -9 | libdeflate -12"
echo "-----|---------|---------|---------------|---------------|---------------"

for file in "$@"; do
	echo -n "$(basename "$file")"
	results=()
	results+=("$(do_benchmark -Y -6)")
	results+=("$(do_benchmark -Y -9)")
	results+=("$(do_benchmark -6)")
	results+=("$(do_benchmark -9)")
	results+=("$(do_benchmark -12)")
	best=2000000000
	for result in "${results[@]}"; do
		if (( result < best)); then
			best=$result
		fi
	done
	for result in "${results[@]}"; do
		if (( result == best )); then
			em="**"
		else
			em=""
		fi
		echo -n " | ${em}${result}${em}"
	done
	echo
done