Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for loop vs every
iterating over an array to test whether every element satisfies a condition the for loop uses "inlining" (the condition is right there, without an extra function call) the call to every uses the predefined lambda ("cond")
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser:
Chrome 142
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 months ago
Test name
Executions per second
for loop
17397888.0 Ops/sec
every
57015796.0 Ops/sec
Script Preparation code:
nums = [1,2,3,4,5,6,7,8,9,10,3,51,124,23,235,-124,25,253,256,315] cond = x => x >= 0;
Tests:
for loop
let result = true; for (let i = 0; i < nums.length; i++) { if (!(nums[i] >= 0)) { result = false; break; } }
every
nums.every(cond);