borc icon indicating copy to clipboard operation
borc copied to clipboard

borc.decodeFirst is 800x slower than it needs to be

Open atg opened this issue 6 years ago • 4 comments

I benchmarked borc against msgpack-lite and JSON for arrays of medium-sized integers (my intended use-case).

Encode performance is within the same order of magnitude, but decode performance is wild (10x100 iterations):

= Decoding Time (ms) =
msgp.decode      1.41
borc.decodeFirst 1227.33
json.parse       1.47

It turns out borc makes a new Decoder() (which does some kind of very heavy initialisation) on every call to borc.decodeFirst(). So perhaps cache the instance of Decoder instead of making a new one each time.

When using a shared decoder, performance is more reasonable (1000x100 iterations):

= Decoding Time (ms) =
msgp.decode      106.46637630462646
borc.decodeFirst 191.69837522506714
json.parse       147.855890750885

atg avatar Aug 23 '18 15:08 atg