Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
for vs. for-of vs. join vs. reduce (concat strings)
Join an array of strings into one string.
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/128.0.0.0 Safari/537.36
Browser:
Chrome 128
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
reduce
2.9M/s
for-of loop
2.7M/s
join
1.4M/s
for loop
139K/s
View exact numbers
Test name
Executions per second
✓
reduce
2,912,310 Ops/sec
for-of loop
2,740,354 Ops/sec
join
1,404,527 Ops/sec
for loop
138,825 Ops/sec
Script Preparation code:
var strings = Array(100).fill("savemyhomeinthe(jungle|polar|ocean|desert)")
Tests:
for loop
let result = "" for (let i = 0; i < strings.length; i++) { result += strings[i] }
for-of loop
let result = "" for (const string of strings) { result += string }
join
const result = strings.join("")
reduce
const result = strings.reduce((a, b) => a + b, "")