Manual fill vs new Buffer vs Native fill

Edit on GitHub

Setup

var bufferSize = 500 * 500;
var globalBuffer = new Uint8Array(bufferSize);

Tests

  • Manual fill

    var n = bufferSize;
    while(n--)
        globalBuffer[n] = 0;
  • new Buffer

    var localBuffer = new Uint8Array(bufferSize);
  • Native fill

    globalBuffer.fill(0);