Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
List of Ids Get Object with Find Object lookup vs IndexOf lookup
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Browser:
Chrome 128
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
indexOf
1675.1 Ops/sec
find
28166.9 Ops/sec
Script Preparation code:
var objects = []; for (var i = 0; i < 10000; i++) { var idx = Math.floor(Math.random() * 1000); objects.push({ index: idx }); } var idx = Math.floor(Math.random() * 1000);
Tests:
indexOf
var objectIndices = []; for (var i = 0; i < 10000; i++) { objectIndices.push(objects[i].index); } var objectIdx = objectIndices.indexOf(idx); var tempResult = objects[objectIdx];
find
var tempResult = objects.find(v => v.index === idx);