HTML Preparation code:
AخA
 
1
<span id="foo"></span>
Script Preparation code:
x
 
const span = document.getElementById ("foo");
class Float32ArrayExtended extends Float32Array {
  
  constructor (val) {
    super(1);
    this[0] = val;
  }
  get x () { return this[0]; }
  set x (v) { this[0] = v; }
}
class Int32ArrayExtended extends Int32Array {
  
  constructor (val) {
    super(1);
    this[0] = val;
  }
  get x () { return this[0]; }
  set x (v) { this[0] = v; }
}
const size = 10000;
const array = new Array(16).fill(1);
const arrayEF32 = new Float32ArrayExtended (16);
const arrayF32 = new Float32Array (16);
const arrayEI32 = new Int32ArrayExtended (16);
const arrayI32 = new Int32Array (16);
let x = 1;
const obj = {
    get x() {
        return array[0];
    },
    set x(value) {
        array[0] = value;
    }
};
Tests:
  • array[0]

     
    let sum = 0;
    for (let i = 0; i < size; i++) {
        array[0] = Math.random () * 1000;
        sum += array[0];
    }
    foo.innerText = sum;
  • set / get

     
    let sum = 0;
    for (let i = 0; i < size; i++) {
        obj.x = Math.random () * 1000;
        sum += obj.x;
    }
    foo.innerText = sum;
  • float 32

     
    let sum = 0;
    for (let i = 0; i < size; i++) {
        arrayF32[0] = Math.random () * 1000;
        sum += arrayF32[0];
    }
    foo.innerText = sum;
  • extended float 32

     
    let sum = 0;
    for (let i = 0; i < size; i++) {
        arrayEF32.x = Math.random () * 1000;
        sum += arrayEF32.x;
    }
    foo.innerText = sum;
  • int 32

     
    let sum = 0;
    for (let i = 0; i < size; i++) {
        arrayI32[0] = Math.random () * 1000;
        sum += arrayI32[0];
    }
    foo.innerText = sum;
  • extended int 32

     
    let sum = 0;
    for (let i = 0; i < size; i++) {
        arrayEI32.x = Math.random () * 1000;
        sum += arrayEI32.x;
    }
    foo.innerText = sum;
  • simple

     
    let sum = 0;
    for (let i = 0; i < size; i++) {
        x = Math.random () * 1000;
        sum += x;
    }
    foo.innerText = sum;
  • array[0] 2

     
    let sum = 0;
    for (let i = 0; i < size; i++) {
        array[0] = Math.random () * 1000;
        sum += array[0];
    }
    foo.innerText = sum;
  • simple 2

     
    let sum = 0;
    for (let i = 0; i < size; i++)
        sum += Math.random () * 1000;
    foo.innerText = sum;
  • simple 3

     
    let sum = 0;
    for (let i = 0; i < size; i++) {
        const x = Math.random () * 1000;
        sum += x;
    }
    foo.innerText = sum;
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    array[0]
    set / get
    float 32
    extended float 32
    int 32
    extended int 32
    simple
    array[0] 2
    simple 2
    simple 3

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one month ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133 on Windows
View result in a separate tab
Test name Executions per second
array[0] 9386.4 Ops/sec
set / get 1117.2 Ops/sec
float 32 8900.2 Ops/sec
extended float 32 9090.9 Ops/sec
int 32 8791.2 Ops/sec
extended int 32 8863.5 Ops/sec
simple 1145.0 Ops/sec
array[0] 2 9573.9 Ops/sec
simple 2 11528.8 Ops/sec
simple 3 11625.6 Ops/sec