Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
find reversed for loop versus find method 4
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/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
reversed for loop
47352.9 Ops/sec
find method =>
52764.2 Ops/sec
find method function
48954.1 Ops/sec
Script Preparation code:
var array = []; for (let i = 0 ; i < 10000 ; i++) { array.push ({ value: Math.floor (Math.random () * 1000) }); }
Tests:
reversed for loop
const value = Math.floor (Math.random () * 100000); let found = undefined; for (let i = array.length - 1 ; i >= 0 ; i--) { const cell = array[i]; if (cell.value === value) { found = cell; break; } }
find method =>
const value = Math.floor (Math.random () * 100000); let found = array.find ((cell) => cell.value === value);
find method function
const value = Math.floor (Math.random () * 100000); let found = array.find (function (cell) { return cell.value === value });