sindresorhus / uint8array-extras

Useful utilities for working with Uint8Array (and Buffer)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performances implications of switching from Buffer to Uint8Array

robertsLando opened this issue · comments

I would be curious to know what are the performances implications about this, will the transition boost or reduce performances? Browser apart where Buffer is polifilled using Uint8Array, Uint8Array could be drammatically slower in nodejs environments compared to Buffer

Performance should in theory be the same for most operations as Buffer is a subclass of Uint8Array.

Buffer does have some unique performance optimizations with pooling, but that also has problems.

The main potential performance problems are encoding/decoding to Base64/Hex as Uint8Array doesn't have any native handling for that, yet. But it really depends on your usage and how performance sensitive your code is. The Hex conversion methods in this package should be pretty fast though.

Thanks for the links provided, I think that creating a banchmark test would be useful to make clear the benefits and the downsides of the move (right now).

if you want some better / faster perf, have a look at: https://github.com/ThaUnknown/uint8-util
i helped out increasing webtorrent speed with this and also the buffer browserified version of eg to/from hex

if you want some better / faster perf, have a look at: https://github.com/ThaUnknown/uint8-util

This is not a useful comment. At minimum explain how it's faster. Ideally, back it up with benchmarks.