Script Preparation code:
x
 
const size = 1024;
var buffer = new ArrayBuffer(size);
var u8View = new Uint8Array(buffer, 0, size);
var buffer2 = new ArrayBuffer(size);
var u8BoolView = new Uint8Array(buffer2, 0, size/8);
var booleanArray = [];
for (let i=0; i<size; i++) {
  const someVal = Math.random()*1;
  //typed array stores (0 or 1)
  u8View[i] = someVal;
  //boolean array stores (false or true)
  booleanArray.push(someVal == 1);
}
for (let i=0; i<size/8; i++) {
  let some256Val = Math.random()*255;
  for (let j=0; j<8; j++) { 
  }
  let FLAG_A = some256Val &= 128;
  let FLAG_B = some256Val &= 64;
  let FLAG_C = some256Val &= 32;
  let FLAG_D = some256Val &= 16;
  let FLAG_E = some256Val &= 8;
  let FLAG_F = some256Val &= 4;
  let FLAG_G = some256Val &= 2;
  let FLAG_H = some256Val &= 1;
  u8BoolView[i] = (FLAG_A | FLAG_B | FLAG_C | FLAG_D | FLAG_E | FLAG_F | FLAG_G | FLAG_H);
}
Tests:
  • boolean array

     
    const resultArray = booleanArray.map(s => {
      return (s == 1);
    });
  • typed Array with uInt8

     
    const resultArray = u8View.map(s => {
      return (s == 1);
    });
  • boolean array - Strict

     
    'use strict';
    const resultArray = booleanArray.map(s => {
      return (s == 1);
    });
  • typed Array with uInt8 - Strict

     
    'use strict';
    const resultArray = u8View.map(s => {
      return (s == 1);
    });
  • weird boolean - Strict

     
    'use strict';
    const resultArray = u8BoolView.map(s => {
      return ((s &= 128) == 1);
    });
  • uint8 .fill()

     
    const resultArray = u8View.fill(1);
  • weird boolean - .fill

     
    const resultArray = u8BoolView.fill(255);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    boolean array
    typed Array with uInt8
    boolean array - Strict
    typed Array with uInt8 - Strict
    weird boolean - Strict
    uint8 .fill()
    weird boolean - .fill

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Safari/605.1.15
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
boolean array 796062.4 Ops/sec
typed Array with uInt8 2178973.2 Ops/sec
boolean array - Strict 717859.2 Ops/sec
typed Array with uInt8 - Strict 2161385.0 Ops/sec
weird boolean - Strict 12857642.0 Ops/sec
uint8 .fill() 52906320.0 Ops/sec
weird boolean - .fill 73618520.0 Ops/sec