Debian Codegraph @

benchmark

raw
1 #!/bin/sh
2
3 BENCHMARK_OUT=benchmark_out
4 HS=../heatshrink
5
6 cd ${BENCHMARK_OUT}
7
8 # Files in the Canterbury Corpus
9 # http://corpus.canterbury.ac.nz/resources/cantrbry.tar.gz
10 FILES='alice29.txt
11 asyoulik.txt
12 cp.html
13 fields.c
14 grammar.lsp
15 kennedy.xls
16 lcet10.txt
17 plrabn12.txt
18 ptt5
19 sum
20 xargs.1'
21
22 rm -f benchmark.output
23
24 # Run several combinations of -w W -l L,
25 # note compression ratios and check uncompressed output matches input
26 for W in 6 7 8 9 10 11 12; do
27 for L in 5 6 7 8; do
28 if [ $L -lt $W ]; then
29 for f in ${FILES}
30 do
31 IN_FILE="${f}"
32 COMPRESSED_FILE="${f}.hsz.${W}_${L}"
33 UNCOMPRESSED_FILE="${f}.orig.${W}_${L}"
34 ${HS} -e -v -w ${W} -l ${L} ${IN_FILE} ${COMPRESSED_FILE} >> benchmark.output
35 ${HS} -d -v -w ${W} -l ${L} ${COMPRESSED_FILE} ${UNCOMPRESSED_FILE} > /dev/null
36
37 # compare file sizes
38 if [ $(ls -l ${IN_FILE} | awk '{print($5)}') != $(ls -l ${UNCOMPRESSED_FILE} | awk '{print($5)}') ];
39 then
40 printf "\n\n\nWARNING: size of %s does not match size of %s\n\n\n" \
41 ${IN_FILE} ${UNCOMPRESSED_FILE}
42 else
43 printf "pass: -w %2d -l %2d %s\n" ${W} ${L} "${f}"
44 fi
45
46 rm ${COMPRESSED_FILE} ${UNCOMPRESSED_FILE}
47 done
48 fi
49 done
50 done
51
52 # Print totals and averages
53 awk '{ t += $2; c++ }; END { printf("====\nTotal compression: %.02f%% for %d documents (avg. %0.2f%%)\n", t, c, t / c) }' benchmark.output