The code is at https://github.com/fiatjaf/nostr-json-benchmarks
(as you can see, the "leaner" codec is much faster than anything else when running on Go.)
The code is at https://github.com/fiatjaf/nostr-json-benchmarks
(as you can see, the "leaner" codec is much faster than anything else when running on Go.)
The is code does not seem optimal.
Avoid using ‘data.buffer.slice()’ as it allocates memory and creates a copy.
Instead use ‘new DataView(data.buffer, byteOffset, byteLength)’ to reference the same buffer.
The javascript code does not seem optimal.
Avoid using ‘data.buffer.slice()’ as it allocates memory and creates a copy.
Have you tried using ‘new DataView(data.buffer, byteOffset, byteLength)’ to reference the same buffer?
If you need more performance, you may also use ‘new Uint8Array(data.buffer, byteOffset, length)’ which is common practice.
No, I did not try. I don't understand why can't we just have a simple byte array and instead have all these weird types. Please send a pull request.