Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
for vs for callback
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/149.0.0.0 Safari/537.36
Browser:
Chrome 149
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 months ago
Benchmark engine:
Benchmark.js
cb
2K/s
for
671/s
View exact numbers
Test name
Executions per second
✓
cb
1,623 Ops/sec
for
671 Ops/sec
Script Preparation code:
window.content = []; for (let i =0; i< 100000; i++) { window.content.push(i); }
Tests:
for
function iterateContent(callback) { for (let i = 0; i < window.content.length; i++) { if (callback(window.content[i])) { break; } } } let sum = 0; iterateContent((char) => { sum += char; });
cb
let sum = 0; for(let i = 0; i< window.content.length;i++) { sum += i; }