sitegui / js-binary

Encode/decode to a custom binary format, much more compact and faster than JSON/BSON
MIT License
91 stars 23 forks source link

In node 0.12 decode is king but encode need some work #2

Closed sitegui closed 7 years ago

sitegui commented 9 years ago

I've just run the same benchmark against native JSON implementation that was created back in the days of node 0.10, but this time against node 0.12

js-binary's decoding wins big: 0.462ms vs 2.829ms (-84%) but the encoding is now slower: 1.989ms vs 2.198ms (11%)

This is an issue to track some improvements in encoding time

sitegui commented 9 years ago

If we pre allocate the right amount (51KiB) to avoid relocs, the speed boost is very considerable:

JSON
        Time: 1.948ms
        Size: 190KiB
js-binary
        Time: 1.989ms (2%)
        Size: 51KiB (3.7x less)
sitegui commented 7 years ago

As of node v8.9.0, the results are even better:

Encode
        JSON
                Time: 2.47ms
                Size: 190KiB
        js-binary
                Time: 1.453ms (-41%)
                Size: 51KiB (3.7x less)
Decode
        JSON
                Time: 2.791ms
        js-binary
                Time: 0.497ms (-82%)