Bit Stream Benchmarks

Implementing Bit Stream Manipulating Programs in Many languages

uudecode

Description

This benchmark implements the uudecode program which is used to transport binary files across networks which only can transfer a subset of all bytecodes reliably. Therefore each 6-bit block in the binary file is translated into a byte value in the range 32-95. The format of the encoded file is as follows:

begin uga filename \n 
X.............................\n
X.............................\n
X.............................\n
 \n
end

Where X is the number of encoded octets in each line + 32. The last line before end only contains a space. Typically the number of encoded octets in a line is 45.

To decode a line, take each 4 byte group (b1,b2,b3,b4) and create a 3 byte group by doing:

((b1-32) << 18) | ((b2-32) << 12) | ((b3-32) << 6) | (b4-32)

If the number of encoded bytes in a line is not evenly divisible by three just scrap the unneeded bytes from the last four-byte group.

To decode the file, decode each line until you find a line starting with space (ASCII 32) then check that the next line starts with end.


Example:

Input:

begin 640 test.file \n 
M,3(S-#4V(&UA9VEC=&5S="!7:'D@=V]U;&0@;VYE(&5N8V]D92!A('1E>'1F\n
::6QE('5S:6YG('5U96YC;V1E/S\_/S\_/PH \n
\n
end

Output:

123456 magictest Why would one encode a textfile using uuencode???????

Time Measurement

The time for this benchmark should be taken from when the file has been loaded and until the decoded string has been created.

Iterations: 100


Source Code

This benchmark has been implemented in the following languages:

  1. C:
  2. Erlang:
  3. Haskell:
  4. O'Caml:
  5. Java:

Example input and output:

testdata.uudecode and testdata.uudecode.out