Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
flat typed array vs 2d typed array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
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
Browser:
Chrome 133
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
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
Script Preparation code:
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);