Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
flat typed array vs 2d typed array
(version: 1)
Comparing performance of:
flat array set vs 2d array set vs flat array get vs 2d array get
Created:
one year ago
by:
Guest
Jump to the latest result
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);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
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:
one year ago
)
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/OS:
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
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
Related benchmarks:
empty an array in JavaScript?
Lodash.js vs Native
Lodash.js vs Native 2
Lodash.js vs Native 112
Wrapped slice
empty an array in JavaScript?(Yorkie)
empty an array in JavaScript - [] vs setting length
Lodash.js vs Nativemmlk
Lodash.js vs Nativee
Comments
Confirm delete:
Do you really want to delete benchmark?