Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
looping test
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/138.0.0.0 Safari/537.36
Browser:
Chrome 138
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
10 months ago
Test name
Executions per second
for loop
248891.8 Ops/sec
foreach loop
242.3 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const styleElement = 666; const mutations = [{ removedNodes: [styleElement], }, ]; for (let i = 0; i < 1000; i++) { for (let j = 0; j < 1000; j++) { if (j === 0) mutations[i] = { removedNodes: [] }; mutations[i]?.removedNodes.push(j); } }
Tests:
for loop
outer: for (let i = 0; i < mutations.length; i++) { const mutation = mutations[i]; const removedNodes = mutation.removedNodes; for (let j = 0; j < removedNodes.length; j++) { const node = removedNodes[j]; if (node === styleElement) { console.log('styleElement removed'); break outer; // Breaks out of both loops } } }
foreach loop
mutations.forEach((mutation) => { mutation.removedNodes.forEach((node) => { if (node === styleElement) { console.log('styleElement removed'); } }); });