HTML Preparation code:
AخA
 
1
<!--your preparation HTML code goes here-->
Script Preparation code:
 
var arr = Array(10_000).fill(1)
Tests:
  • Reduce with empty erray

     
    arr.reduce((acc, x) => {
        acc.push(x);
        return acc;
    }, []);
  • Reduce with filled array

     
    arr.reduce((acc, x, index) => {
        acc[index] = x;
        return acc;
    }, new Array(arr.length));
  • Reduce with filled array with null

     
    arr.reduce((acc, x, index) => {
        acc[index] = x;
        return acc;
    }, new Array(arr.length).fill(null));
  • Reduce with new Array

     
    arr.reduce((acc, x, index) => {
        acc[index] = x;
        return acc;
    }, new Array());
  • Reduce with var

     
    const a = new Array(arr.length);
    arr.reduce((acc, x, index) => {
        acc[index] = x;
        return acc;
    }, a);
  • Reduce with var []

     
    const a = [];
    arr.reduce((acc, x, index) => {
        acc.push(x)
        return acc;
    }, a);
  • Reduce with var [] assign by index

     
    const a = [];
    arr.reduce((acc, x, index) => {
        acc[index] = x;
        return acc;
    }, a);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Reduce with empty erray
    Reduce with filled array
    Reduce with filled array with null
    Reduce with new Array
    Reduce with var
    Reduce with var []
    Reduce with var [] assign by index

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 5 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Chrome 130 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Reduce with empty erray 10601.3 Ops/sec
Reduce with filled array 5860.2 Ops/sec
Reduce with filled array with null 6316.3 Ops/sec
Reduce with new Array 5628.4 Ops/sec
Reduce with var 21483.9 Ops/sec
Reduce with var [] 14137.6 Ops/sec
Reduce with var [] assign by index 3608.6 Ops/sec