Coder Social home page Coder Social logo

Comments (5)

kawanet avatar kawanet commented on September 4, 2024 3

0.1.26 published. Thanks!

from msgpack-lite.

maciejhirsz avatar maciejhirsz commented on September 4, 2024

Note: benchmarking things on my own, I found that building strings by simply concatenating to a string via += operator is faster than creating a preallocated array and calling String.fromCharCode.apply.

from msgpack-lite.

kawanet avatar kawanet commented on September 4, 2024

building strings by simply concatenating to a string via += operator is faster than creating a preallocated array and calling String.fromCharCode.apply.

Really!?!? I was pretty surprised with this!

https://github.com/feross/buffer/blob/master/index.js#L997
Buffer shim is also use the same String.fromCharCode.apply technique still.

I guess that buffer-lite.js on the master branch creates two Arrays at least on toString. It may cost. Building/parsing string would give the most impact for decoding/encoding performance. I'd love to see it in depth.

Thanks for the great patch anyway.

from msgpack-lite.

maciejhirsz avatar maciejhirsz commented on September 4, 2024

Note: the benchmarks I was running for this were on Node 6.3 and Chrome Canary 54, so take it with a big grain of salt, different browsers might vary.

For longer stings (>~128) if your buffer happens to be Uint8Array, the absolutely fastest string decoding you can get is by passing a Uint8Array#subarray to TextDecoder#decode - it's comparable in performance to using Buffer#toString in Node.js, and beats JSON.parse. The threshold is whatever the cost there is to initialize a new TypedArray, which seems to always be in the range of 100 - 500 ns on my hardware for whatever reason, even when using already allocated ArrayBuffer.

from msgpack-lite.

gordomium avatar gordomium commented on September 4, 2024

Hope it be fixed

from msgpack-lite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.