Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Joining strings 3
(version: 1)
Comparing performance of:
join vs for loop concatenation
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ const a = []; async function globalMeasureThatScriptPrepareFunction() { // This function is optional, feel free to remove it. // await someThing(); for(let i = 0; i < 100000; i++) { const x = Math.floor(Math.random() * 1000); const y = Math.floor(Math.random() * 1000); a.push({ x, y }); } }
Tests:
join
const d = a.map(path => `${path.x.toFixed(0)},${path.y.toFixed(0)}`).join(' '); `M${d}`
for loop concatenation
let b = 'M'; for(let j = 0; j < a.length; j++) { const point = a[j]; const x = point.x.toFixed(0); const y = point.y.toFixed(0); b += x + ',' + y + ' '; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
join
for loop concatenation
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Browser/OS:
Chrome 133 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
join
22.9 Ops/sec
for loop concatenation
27.2 Ops/sec
Related benchmarks:
String concatenation vs element creation 2
Set merge
Test array concat
Test array concat with larger array
Multiplication vs Math.exp
generateRandomString
Hihihihi
Joining strings
Joining strings 2
Comments
Confirm delete:
Do you really want to delete benchmark?