Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
forEach, for, for-of, map
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/132.0.0.0 Safari/537.36
Browser:
Chrome 132
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
forEach()
1147142.6 Ops/sec
for of
1160329.9 Ops/sec
map()
1039984.9 Ops/sec
for
1017532.7 Ops/sec
Script Preparation code:
const urls = [ 'http://localhost:3000/DEFAULT/allow/any', 'http://localhost:3000/DEFAULT/disallow/any', 'http://localhost:3000/DEFAULT/allow/file-type/*.png', 'http://localhost:3000/DEFAULT/allow/ended-url$', 'http://localhost:3000/DEFAULT/allow/query-string?id=rapid7/*.txt', 'http://localhost:3000/slurp/allow/any', 'http://localhost:3000/slurp/disallow/any', 'http://localhost:3000/msnbot/allow/any', 'http://localhost:3000/msnbot/disallow/any', 'http://localhost:3000/googlebot/allow/any', 'http://localhost:3000/googlebot/disallow/any' ];
Tests:
forEach()
let regexes = [/\/googlebot\/disallow\/any/, /slurp/]; let urls = [ 'http://localhost:3000/DEFAULT/allow/any', 'http://localhost:3000/DEFAULT/disallow/any', 'http://localhost:3000/DEFAULT/allow/file-type/*.png', 'http://localhost:3000/DEFAULT/allow/ended-url$', 'http://localhost:3000/DEFAULT/allow/query-string?id=rapid7/*.txt', 'http://localhost:3000/slurp/allow/any', 'http://localhost:3000/slurp/disallow/any', 'http://localhost:3000/msnbot/allow/any', 'http://localhost:3000/msnbot/disallow/any', 'http://localhost:3000/googlebot/allow/any', 'http://localhost:3000/googlebot/disallow/any' ]; urls.forEach((url) => { regexes.forEach((regex) => { if (regex.test(url)) { urls = urls.filter((item) => item !== url); } }); });
for of
let regexes = [/\/googlebot\/disallow\/any/, /slurp/]; let urls = [ 'http://localhost:3000/DEFAULT/allow/any', 'http://localhost:3000/DEFAULT/disallow/any', 'http://localhost:3000/DEFAULT/allow/file-type/*.png', 'http://localhost:3000/DEFAULT/allow/ended-url$', 'http://localhost:3000/DEFAULT/allow/query-string?id=rapid7/*.txt', 'http://localhost:3000/slurp/allow/any', 'http://localhost:3000/slurp/disallow/any', 'http://localhost:3000/msnbot/allow/any', 'http://localhost:3000/msnbot/disallow/any', 'http://localhost:3000/googlebot/allow/any', 'http://localhost:3000/googlebot/disallow/any' ]; for (const url of urls) { for (const regex of regexes) { if (regex.test(url)) { urls = urls.filter(item => item !== url) } } }
map()
let regexes = [/\/googlebot\/disallow\/any/, /slurp/]; let urls = [ 'http://localhost:3000/DEFAULT/allow/any', 'http://localhost:3000/DEFAULT/disallow/any', 'http://localhost:3000/DEFAULT/allow/file-type/*.png', 'http://localhost:3000/DEFAULT/allow/ended-url$', 'http://localhost:3000/DEFAULT/allow/query-string?id=rapid7/*.txt', 'http://localhost:3000/slurp/allow/any', 'http://localhost:3000/slurp/disallow/any', 'http://localhost:3000/msnbot/allow/any', 'http://localhost:3000/msnbot/disallow/any', 'http://localhost:3000/googlebot/allow/any', 'http://localhost:3000/googlebot/disallow/any' ]; urls.map(url => { regexes.map(regex => { if (regex.test(url)) { urls = urls.filter(item => item !== url) } }) })
for
let regexes = [/\/googlebot\/disallow\/any/, /slurp/]; let urls = [ 'http://localhost:3000/DEFAULT/allow/any', 'http://localhost:3000/DEFAULT/disallow/any', 'http://localhost:3000/DEFAULT/allow/file-type/*.png', 'http://localhost:3000/DEFAULT/allow/ended-url$', 'http://localhost:3000/DEFAULT/allow/query-string?id=rapid7/*.txt', 'http://localhost:3000/slurp/allow/any', 'http://localhost:3000/slurp/disallow/any', 'http://localhost:3000/msnbot/allow/any', 'http://localhost:3000/msnbot/disallow/any', 'http://localhost:3000/googlebot/allow/any', 'http://localhost:3000/googlebot/disallow/any' ]; for (let i = urls.length - 1; i >= 0; i--) { for (let j = regexes.length - 1; j >= 0; j--) { if (regexes[j].test(urls[i])) { urls = urls.filter(item => item !== urls[i]) } } }