[David Fang] "huff_enc" takes a data file and generates a Huffman code tree output to a file. /********************************************************************** * File: huff_enc.c * * Function: Huffman encodes an input file assuming a 256 letter * * alphabet * * Author : S. Faltys * * Last mod: 7/21/95 * * Usage: see usage(), for details see man page or huff_enc.doc * ***********************************************************************/ I chose this program because I am familiar with the algorithm used for encoding and decoding. It is a really simple program whose execution profile should be relatively independent of the input data. i.e. the data size should only affect the frequency of execution without significantly affecting branching decisions. (I've written my own adaptive_huffman encoder/decoder, but couldn't get C++ code to compile right with the new compiler.) The encoding algorithm generates a Huffman tree as a code and saves it to a code file, and on another pass, uses that code to compress the binary image file into a compressed bitstream. For the benchmarks below, a 64K input image file was used. ------------------------------------------------------------------------------- Benchmark Comparison Summary unoptimized -O3 optimized #inst exec'd 19.6 M 7.2 M sim time 51 s 16 s instruction class profile load 7.5 M (38%) 1.2 M (17%) store 2.3 M (12%) .2 M (3%) uncond br. .7 M (4%) <.1 M (1%) cond. br. 1.6 M (8%) 1.6 M (22%) int comp. 7.3 M (37%) 4 M (56%) fp comp. .1 M (.5%) .1 M (1%) Top 10 instructions lw 6.1 M (31%) addiu 1.7 M (24%) addu 3.7 M (19%) bne 1.4 M (19%) sw 1.8 M (9%) sll 730 k (10%) addiu 1.6 M (8%) slt 630 k (9%) bne 1.4 M (7%) addu 530 k (7%) sll 930 k (4%) lw 460 k (6%) j 725 k (4%) lb 450 k (6%) slt 690 k (4%) and 320 k (4%) lbu 640 k (3%) lbu 170 k (2%) sb 550 k (3%) l.s 130 k (2%) from text: SPECint92 top 5 (from fig. 2.11) load 22% cond. br. 20% compare 15% store 12% add 8%