commit | author | age
|
107e65
|
1 |
#!/bin/bash |
JG |
2 |
|
|
3 |
function test-comp() { |
|
4 |
#compress file |
|
5 |
$1 -$2 -c test.tar > "test.$2.$3" 2>/dev/null |
|
6 |
#write file size to temp file for csv formation |
|
7 |
printf "$(wc -c test.$2.$3 | awk '{print $1}')\n" >> $3 |
|
8 |
#remove file |
|
9 |
rm -f "test.$2.$3" |
|
10 |
} |
|
11 |
|
|
12 |
function test-bzip2() { |
|
13 |
rm -f "bz2" |
|
14 |
for i in {1..9}; do |
|
15 |
test-comp bzip2 $i "bz2" |
|
16 |
done |
|
17 |
} |
|
18 |
|
|
19 |
function test-gzip() { |
|
20 |
rm -f "gz" |
|
21 |
for i in {1..9}; do |
|
22 |
test-comp gzip $i "gz" |
|
23 |
done |
|
24 |
} |
|
25 |
|
|
26 |
function test-lz4() { |
|
27 |
rm -f "lz4" |
|
28 |
for i in {1..12}; do |
|
29 |
test-comp lz4 $i "lz4" |
|
30 |
done |
|
31 |
} |
|
32 |
|
|
33 |
function test-xz() { |
|
34 |
rm -f "xz" |
|
35 |
for i in {1..9}; do |
|
36 |
test-comp xz $i "xz" |
|
37 |
done |
|
38 |
} |
|
39 |
|
|
40 |
function test-xz-e() { |
|
41 |
rm -f "xze" |
|
42 |
for i in {1..9}; do |
|
43 |
test-comp "xz -e" $i "xze" |
|
44 |
done |
|
45 |
} |
|
46 |
|
|
47 |
function test-lzma() { |
|
48 |
rm -f "lzma" |
|
49 |
for i in {1..9}; do |
|
50 |
test-comp lzma $i "lzma" |
|
51 |
done |
|
52 |
} |
|
53 |
|
|
54 |
function test-lzma-e() { |
|
55 |
rm -f "lzmae" |
|
56 |
for i in {1..9}; do |
|
57 |
test-comp "lzma -e" $i "lzmae" |
|
58 |
done |
|
59 |
} |
|
60 |
|
|
61 |
function test-zstd() { |
|
62 |
rm -f "zst" |
|
63 |
for i in {1..19}; do |
|
64 |
test-comp zstd $i "zst" |
|
65 |
done |
|
66 |
for i in {20..22}; do |
|
67 |
test-comp "zstd --ultra" $i "zst" |
|
68 |
done |
|
69 |
} |
|
70 |
|
|
71 |
if [ -z $1 ]; then |
|
72 |
echo "Usage: $0 FILES" |
|
73 |
exit |
|
74 |
fi |
|
75 |
|
|
76 |
# create a tar file to deal with directories |
|
77 |
tar -cf test.tar "$@" |
|
78 |
|
|
79 |
# run tests with all algorithms/programs |
|
80 |
rm -f results.csv |
|
81 |
ALGS=(bzip2 gzip lz4 xz xz-e lzma lzma-e zstd) |
|
82 |
for i in ${ALGS[*]}; do |
|
83 |
test-$i |
|
84 |
done |
|
85 |
rm -f test.tar |
|
86 |
|
|
87 |
# create csv with vertical columns |
|
88 |
ALG_RES=`find . -maxdepth 1 -not -name '*.*' -type f` |
|
89 |
printf "level" >> results.csv |
|
90 |
for i in ${ALG_RES[*]}; do |
|
91 |
printf ",%s" $(echo $i | sed 's/\.\///') >> results.csv |
|
92 |
done |
|
93 |
printf "\n" >> results.csv |
|
94 |
|
|
95 |
for i in {1..22}; do |
|
96 |
printf "$i" >> results.csv |
|
97 |
for j in $ALG_RES; do |
|
98 |
k=1; |
|
99 |
FOUND=0; |
|
100 |
while read LINE; do |
|
101 |
if [ $k == $i ]; then |
|
102 |
printf ",$LINE" >> results.csv |
|
103 |
FOUND=1 |
|
104 |
break |
|
105 |
fi |
|
106 |
k=$((k+1)) |
|
107 |
done < $j |
|
108 |
[ $FOUND == 0 ] && printf "," >> results.csv |
|
109 |
done |
|
110 |
printf "\n" >> results.csv |
|
111 |
done |
|
112 |
for i in ${ALG_RES[*]}; do |
|
113 |
rm -f $i |
|
114 |
done |
|
115 |
|
|
116 |
# generate plot using gnuplot |
|
117 |
read -p "Generate plot? Y/n " PLOT |
|
118 |
if [[ -z $PLOT || $PLOT == "y" || $PLOT == "Y" ]]; then |
|
119 |
gnuplot -e "set datafile separator \",\"; \ |
a96505
|
120 |
set term svg; \ |
JG |
121 |
set output 'results.svg'; \ |
107e65
|
122 |
plot for [col=2:$((${#ALGS[@]}+1))] 'results.csv' using 1:col with lines title columnheader" |
JG |
123 |
fi |