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:
5 months ago
every
57.0M/s
for loop
17.4M/s
View exact numbers
Test name
Executions per second
✓
every
57,015,796 Ops/sec
for loop
17,397,888 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);