JSON compression in JavaScript
This page presents measurements of various compression techniques applied to 100000 bytes of real-world JSON data.
Only forward transformations/compression was tested, no inverses and/or decompression.
All tests were executed on Intel E6750 with 32bit Windows XP, Firefox 3.6.
Contestants
-
MTF - Move To Front transformation,
implemented using a 256-byte array.
-
BWT - Burrows-Wheeler transformation,
implemented using Array.prototype.sort() applied to an array of indexes.
-
LZW - Lempel-Ziv-Welch algorithm. Operates in
two modes:
- variable output width (slower, default), using 8 to 16 bits per output number
- fixed output width (faster), using 16 bits per output number
Results
Single
Algorithm |
Size (bytes) |
Time (msec) |
MTF |
100000 |
330 |
BWT |
100001 |
11011 |
LZW - variable output width |
18274 |
174 |
LZW - fixed output width |
22970 |
110 |
Remarks:
- MTF and BWT are not compression algorithms; they are shown here just to demonstrate their performance.
Combined
Algorithm |
Size (bytes) |
Time (msec) |
MTF + LZW |
33000 |
540 |
BWT + LZW |
9906 |
11159 |
BWT + MTF + LZW |
7070 |
11577 |
Remarks:
- It is currently not possible to run BWT after MTF, due to the way BWT is implemented
(certain special byte, \0, must not be present in input data).
BWT + MTF + LZW using smaller chunks
Chunk size (bytes) |
Size (bytes) |
Time (msec) |
5000 |
14956 |
5862 |
10000 |
11285 |
7110 |
20000 |
8869 |
8336 |
50000 |
7556 |
10209 |
TODO
- Optimize BWT encoding implementation
- Benchmark inverse transformations and decompression
© 2010 Ondrej Zara