9 ms·
I just ran that experiment: https://gist.github.com/ggreer/4eb3ad61e97926e559f6 https://gist.github.com/ggreer/4eb3ad61e97926e559f6 ASCII is extremely repetiti
by ggreer 11y ago
I just ran that experiment: https://gist.github.com/ggreer/4eb3ad61e97926e559f6 https://gist.github.com/ggreer/4eb3ad61e97926e559f6
ASCII is extremely repetitive. 1MB of random braces gzips down to 163KB. That's a compression ratio of 6.1:1. Optimal compression would be close to 8:1 (since each byte really contains only one bit of information).
- forgottenpass 11y agofor (let i = 0; i < 1024 * 1024; i++) { buf += Math.random() > 0.5 ? "{" : "}"; } Your sample data is bunk for determining the compression characteristics of braces in a realistic json file.
- ggreer 11y agoThe point was to show that compression works at the level of bits, not characters. Realistic JSON is mostly content, which means your compression ratio depends more on content redundancies than braces or quotes. So too for binary serialization formats.