Skip to content

Instantly share code, notes, and snippets.

@Arkanosis
Created October 12, 2015 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arkanosis/2e68ecee21ed2f7af1ae to your computer and use it in GitHub Desktop.
Save Arkanosis/2e68ecee21ed2f7af1ae to your computer and use it in GitHub Desktop.
Naive benchmark of compressors
#! /usr/bin/env zsh
# Naive benchmark of compressors
# (C) 2015 Jérémie Roquet <jroquet@arkanosis.net>
# Disclaimer: only one run per program to get an idea, do not rely on the results!
# TODO wrapper for lzham because lzhamtest is not pipe-friendly (it needs to know the input size)
file=frwiki-20151002.xml
export TIMEFMT='%U'
get() {
head -c $1 $file
}
bench() {
(
{
get $1 |
(
time $=2
)
} > >(
wc -c
) > >(
(
time $=3 > /dev/null
)
)
) 2>&1 | tr '\n' ' '
echo \| $@[1,2]
}
bench_all() {
echo --- bench@$1 ---
bench $1 'lz4 -1' 'lz4 -d'
bench $1 'lz4 -5' 'lz4 -d'
bench $1 'lz4 -9' 'lz4 -d'
bench $1 'gzip -1' 'gunzip'
bench $1 'gzip -5' 'gunzip'
bench $1 'gzip -9' 'gunzip'
bench $1 'bro --quality 1' 'bro --decompress'
bench $1 'bro --quality 4' 'bro --decompress'
bench $1 'bro --quality 9' 'bro --decompress'
bench $1 'bro --quality 11' 'bro --decompress'
bench $1 'bzip2 -1' 'bunzip2'
bench $1 'bzip2 -5' 'bunzip2'
bench $1 'bzip2 -9' 'bunzip2'
bench $1 'xz -0' 'unxz'
bench $1 'xz -6' 'unxz'
bench $1 'xz -9e' 'unxz'
}
for size in 5k 50k 500k 5M 50M; do
bench_all $size
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment