compress-json icon indicating copy to clipboard operation
compress-json copied to clipboard

Add lzwCompress.js and lz-string to the benchmarks

Open J3m5 opened this issue 2 years ago • 3 comments

It would be nice to be able to compare your library to those: https://github.com/floydpink/lzwCompress.js https://github.com/pieroxy/lz-string

Would it be possible to add them to the benchmarks ? Thanks

J3m5 avatar Aug 30 '21 14:08 J3m5

Good suggestion, you can add tests (benchmark) for these library following the tests in https://github.com/beenotung/compress-json/blob/05665812cb98aba0a0044bdea16495f4e3d765c7/test/compress-test.ts#L88-L113

beenotung avatar Aug 31 '21 16:08 beenotung

lz-string seems to be binary compression, may not be fair comparison (because the underline storage engine may need to escape binary string before storing them which can add the storage size significantly);

I do not have access to the original sample data at the moment. Just did a trial with lzwcompress on another 50k sample data from the same online forum dataset.

Number of sample object: 50,000

- JSON compressed-json compress-json lzwcompress
Compressed Size 45M 36M 34M 42M
Compress Time 197ms 1.6s 2.6s 6.3s
Decompress Time 274ms 569ms 1.6s 560ms
Exact Match* Yes No Yes No

Remark: exact match consider whevether the order of object key is preserved when decompressed from the compressed representation.

beenotung avatar Aug 31 '21 17:08 beenotung

In fact, the one I was the most interested in is lz-string. I'll look into it, thank you very much!

J3m5 avatar Sep 01 '21 08:09 J3m5