Script Preparation code:
x
 
var arrDim = 1000;
var clArr = new Array(arrDim);
for (var i = 0; i < arrDim; i++) {
    clArr[i] = new Uint8Array(arrDim);
}
clArr.getSlice = function(i) {
    return this[i];
}
clArr.setVal = function(i, j, val) {
    this[i][j] = val;
}
clArr.getVal = function(i, j) {
    return this[i][j];
}
var flArr = new Uint8Array(Math.pow(arrDim, 2));
flArr.getSlice = function(i) {
    var start = i*arrDim;
    return this.slice(start, start + arrDim);
}
flArr.setVal = function(i, j, val) {
    this[i*arrDim + j] = val;
}
flArr.getVal = function(i, j) {
    return this[i*arrDim + j];
}
Tests:
  • flat array set

     
     flArr.setVal(123, 123, 1);
  • 2d array set

     
    clArr.setVal(123, 123, 1);
  • flat array get

     
    flArr.getVal(123, 123);
  • 2d array get

     
    clArr.getVal(123, 123);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    flat array set
    2d array set
    flat array get
    2d array get

    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/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
flat array set 260144480.0 Ops/sec
2d array set 239926224.0 Ops/sec
flat array get 274478304.0 Ops/sec
2d array get 241388304.0 Ops/sec