Created
September 9, 2013 19:40
-
-
Save x2q/6500451 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
NBLOOP=3 | |
COMPRESS_OBJECT=db/ | |
memstats() | |
{ | |
( | |
renice 19 $$ >/dev/null 2>&1 | |
while : ; do | |
ps --no-headers -o rss -C $1 || break | |
sleep 1 | |
done | tail -n 1 | |
) | |
} | |
bench() | |
{ | |
for i in $(seq 1 $NBLOOP) ; do | |
trap "rm -f out.$2" EXIT | |
/usr/bin/time -f "DONE: comp $1-$3 ($i) time: %e" tar cf out.$2 $COMPRESS_OBJECT --$1 2>&1 >/dev/null & sleep 1 | |
mem=$(memstats $1) | |
size=$(stat -c '%s' out.$2) | |
echo "... mem: $mem size: $size" | |
echo | |
mkdir tmp_extract_$$ || exit 1 | |
trap "rm -f out.$2 ; rm -Rf tmp_extract_$$" EXIT | |
/usr/bin/time -f "DONE: decomp $1-$3 ($i) time: %e" tar xf out.$2 -C tmp_extract_$$ 2>&1 >/dev/null & sleep 1 | |
mem=$(memstats $1) | |
echo "... mem: $mem" | |
echo | |
rm -f out.$2 | |
rm -Rf tmp_extract_$$ | |
trap - EXIT | |
done | |
} | |
#for level in none ; do | |
# echo "=== COMPRESS ===" | |
# bench compress Z | |
#done | |
for level in 1 3 7 8 9 ; do | |
echo "=== LZOP -$level ===" | |
export LZOP="-$level" | |
bench lzop lzo $level | |
done | |
for level in 1 2 3 4 5 6 7 8 9 ; do | |
echo "=== GZIP -$level ===" | |
export GZIP="-$level" | |
bench gzip gz $level | |
done | |
for level in 1 2 3 4 5 6 7 8 9 ; do | |
echo "=== BZIP2 -$level ===" | |
export BZIP2="-$level" | |
bench bzip2 bz2 $level | |
done | |
for level in 0 1 2 3 4 5 6 7 8 9 ; do | |
echo "=== LZMA -$level ===" | |
export XZ_OPT="-$level" | |
bench lzma lzma $level | |
done | |
for level in 0 1 2 3 4 5 6 7 8 9 ; do | |
echo "=== XZ (LZMA2) -$level ===" | |
export XZ_OPT="-$level" | |
bench xz xz $level | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment