Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Roop Performance: while vs for vs call myself
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Browser:
Chrome 128
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
for
91K/s
while roop
91K/s
call myself
62K/s
View exact numbers
Test name
Executions per second
✓
for
91,455 Ops/sec
while roop
91,320 Ops/sec
call myself
61,779 Ops/sec
Script Preparation code:
var count = 10000; var target = []; for(let i = 0; i < count; i++) { target[i] = i; }
Tests:
while roop
var sum = 0; var i = 0; while(sum < 70000) { sum += target[i]; i++; }
for
var sum = 0; for(let i = 0; sum < 70000; i++) { sum += target[i]; }
call myself
var sum = 0; var i = 0; var sumFunction = (num) => { sum += target[num]; i++; if(sum < 70000) sumFunction(i); }; sumFunction(i);