Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
atg opened this issue Aug 23, 2018 · 4 comments
Open

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

atg opened this issue Aug 23, 2018 · 4 comments

Comments

@atg
Copy link

atg commented Aug 23, 2018

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
@dignifiedquire
Copy link
Owner

Yes, if you know you are doing a lot of decodes, the api is intended to not use the static methods, but rather manage your own instance.

@dignifiedquire
Copy link
Owner

So the real fix here, is to update the documentation, the caching of the instance should be the job of the user, as they will know much better what to do with hit.

@atg
Copy link
Author

atg commented Aug 23, 2018

A bug is still a bug whether documented or not. ¯\(ツ)

@dignifiedquire
Copy link
Owner

dignifiedquire commented Aug 23, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants