Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
string characters split map vs for loop vs split foreach
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0
Browser:
Firefox 109
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
split foreach
6.9M/s
for loop
6.4M/s
split map
5.2M/s
View exact numbers
Test name
Executions per second
✓
split foreach
6,875,314 Ops/sec
for loop
6,356,620 Ops/sec
split map
5,233,063 Ops/sec
Tests:
split map
const string = 'asdf1234qwer'; const mapper = (char) => String.fromCharCode(char.charCodeAt(0)) string.split('').map(mapper).join('')
for loop
const string = 'asdf1234qwer'; const mapper = (char) => String.fromCharCode(char.charCodeAt(0)) let result = "" for(const char of string) { result += mapper(char) }
split foreach
const string = 'asdf1234qwer'; const mapper = (char) => String.fromCharCode(char.charCodeAt(0)) let result = '' string.split('').forEach(char => { result += mapper(char) })