Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Check attributes
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:
9 months ago
Test name
Executions per second
for loop
285876448.0 Ops/sec
string
255186720.0 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const CLOSE_KEYWORDS = ['close', 'exit', 'quit', 'cancel', 'dismiss']; const attrCount = 1000; // adjust for testing const matchIndex = 0; // index where matching attribute is placed (0 = early match) const el = document.createElement('div'); // Generate many attributes for (let i = 0; i < attrCount; i++) { const value = (i === matchIndex) ? 'please close this' : `attr${i}`; el.setAttribute(`data-${i}`, value); } // Warmup checkWithEarlyExit(el, CLOSE_KEYWORDS); checkWithFullJoin(el, CLOSE_KEYWORDS);
Tests:
for loop
function checkWithEarlyExit(el, keywords) { for (const attr of el.attributes) { const val = attr.value.toLowerCase(); if (keywords.some(keyword => val.includes(keyword))) { return true; } } return false; }
string
function checkWithFullJoin(el, keywords) { const allAttrValues = Array.from(el.attributes, attr => attr.value.toLowerCase()).join(' '); return keywords.some(keyword => allAttrValues.includes(keyword)); }