simplehuffman is a simple Huffman encoding/decoding program written in C. While it was written primarily as an exercise in clean coding and optimization, it can indeed encode and decode files, and for large ASCII text files it achieves compression of typically around 35%.
The original simplehuffman.c code was written to be easy to read, with no attention paid to optimization opportunities.
I benchmarked the different versions by encoding and decoding the same 75MB tar/gz file. The net improvement between the first and fourth version of the program is around 3.5x, both for encoding and decoding. The final version is encoding at 35MB/s+ and decoding at 11MB/s+.
|Version||Encode (time)||Speedup||Decode (time)||Speedup|
Executables were built with gcc 4.6.1 using -O3 optimizations, and run on a 1.6GHZ AMD Sempron processor.