cbor-x icon indicating copy to clipboard operation
cbor-x copied to clipboard

Browser performance vs nodejs performance?

Open ranaya-formant opened this issue 2 years ago • 1 comments

Is there any difference?

ranaya-formant avatar May 05 '22 18:05 ranaya-formant

Yes, there is a difference. Most notably, cbor-x employs a native node module (cbor-extract) that accelerates text decoding. This is an "optional" module, cbor-x works fine without it (it isn't available in the browser), but is loaded in nodejs, and can and usually significantly improves decoding performance (typically by about 40-50%, I'd estimate).

Even apart from that, there do tend to be other smaller differences in performance. For example, chrome uses pointer compression and nodejs doesn't, which can impact performance. And of course there are non-chrome/V8 browsers with different performance characteristic.

However, in an effort to close this gap, cbor-x does have an extension, the bundleStrings flag that is designed for much faster decoding in the browser.

Generally, encoding performance is more similar between nodejs and browser, although you will probably some small differences.

kriszyp avatar May 05 '22 18:05 kriszyp