Bit Stream Benchmarks

Implementing Bit Stream Manipulating Programs in Many languages



This benchmark implements the uuencode 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 

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. The three characters after 'begin' ('uga' in the above example) denote the user-group-all access rights of the encoded file. To simplify the task, the benchmark is allowed to ignore this and just make up some access right for the resulting file. The filename should be correct though.

To create a uuencoded line from a file take 45 bytes of input from the file and put M first in the file. This M (ASCII 77) signifies that 45 octets have been encoded on this line. Then for each three byte group (b1,b2,b3) of input create a four byte (b1',b2',b3',b4') group by doing:

b1' = ((b1 >> 2) & 63)+32, 
b2' = (((b1 << 4) | (b2 >> 4)) & 63)+32, 
b3' = (((b2 << 2) | (b3 >> 6)) & 63)+32,
b4' = (b3 & 63)+32,

When less than 45 bytes remain, the last line is encode by putting the number of bytes encoded in this line added by 32. In other words, if 11 bytes remain the first character in the last line is '+' (ASCII 43). Otherwise the line is encoded as the others except if there is not an integer number of 3-byte groups. If there is one or two extra bytes the output should be padded with '='



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


begin 640 test.file \n 
::6QE('5S:6YG('5U96YC;V1E/S\_/S\_/PH \n

Time Measurement

The time for this benchmark should be taken from when the file has been loaded and until the encoded 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.uuencode and testdata.uuencode.out