This repository contains a Python module to compute the Weissman Score of a compression algorithm.
The Weissman Score is a fictional performance score for lossless data compression algorithms devised by Tsachy Weissman and Vinith Misra at Stanford University and used in the HBO comedy series Silicon Valley.
The Weissman score W is computed as:
W = alpha * r/rb * log(Tb)/log(T)
where r and T refer to the compression ratio and time-to-compress of the target algorithm, rb and Tb refer to same quantities for a standard universal compressor (this implementation uses gzip) and alpha is a scaling constant.
Further information here and here.
You can run the script as follows:
python weissman.py -c <command> -i <input> -o <output> -a <alpha> -r <reps>
Where:
command
is the command to launch the target compression algorithm and compress a specificinput
file into theoutput
file. This command must keep the original (uncompressed) fileinput
is the path to the uncompressed file used in the testoutput
is the path to the compressed file generated bycommand
alpha
is the scaling parameter of the Weissman scorereps
is the number of times the experiment needs to be repeated (mean values are taken to compute the score)
A trivial usage example to compute bzip score is:
python weissman.py -c "bzip2 --keep README.md" -i README.md -o README.md.bz2 -a 1.0 -r 5
This code can also be used within a Python program:
>>> import weissman
>>> weissman.weissman("bzip2 --keep README.md", "README.md", "README.md.bz2", alpha=1.0, reps=5)