-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbenchmark.sh
executable file
·35 lines (29 loc) · 935 Bytes
/
benchmark.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
#! /bin/bash
# generate all.c
if [ ! -f all.c ]; then
cat *.h *.cpp > _all.c
(for ((i=0;i<10;++i)); do cat _all.c; done) > all.c
rm _all.c
fi
# generate main10
if [ ! -f main10 ]; then
(for((i=0;i<30;++i)); do cat main; done) > main10
fi
# generate bigFile
if [ ! -f bigFile ]; then
./createBigFile.sh 64
fi
algos="rle rle_2 rle_4 huff_4k huff_16k huff_64k lzw_16k lzw_128k lzw_1024k lz77_16k lz77_128k lz77_1024k"
testFiles="all.c pch.h.gch main10 bigFile"
for f in $testFiles; do
echo $f ":"
for algo in $algos; do
result=`(bash -c "time ./main -a $algo -i $f -o ${f}_x" 2>&1; bash -c "time ./main -x -a $algo -i ${f}_x -o ${f}_x2" 2>&1; du -b $f; du -b ${f}_x) | python benchmark_help.py`
if diff $f ${f}_x2 > /dev/null ;then
printf "\t%20s : %s %s %s\n" $algo $result
else
echo "failed: $algo"
fi
rm -r ${f}_x ${f}_x2
done
done