Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
String concatenation vs array join Chrome 4
(version: 0)
Comparing performance of:
String concatentation vs Array join (w/ push)
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var str = ""; var i; var sArr = []; function encodePush(str) { if (!str || !str.length) { return ''; } var strLength = str.length; var result = []; var i = 0; while (i < strLength) { var charInfo = charIndex[str.charCodeAt(i)]; if (charInfo) { var alpha = charInfo[str.charCodeAt(i + 1)]; if (alpha) { i++; } else { alpha = charInfo['']; } if (alpha) { result.push("&"+alpha+";"); i++; continue; } } result.push(str.charAt(i)); i++; } return result.join(''); } function encodePlus(str) { if (!str || !str.length) { return ''; } var strLength = str.length; var result = ''; var i = 0; while (i < strLength) { var charInfo = charIndex[str.charCodeAt(i)]; if (charInfo) { var alpha = charInfo[str.charCodeAt(i + 1)]; if (alpha) { i++; } else { alpha = charInfo['']; } if (alpha) { result += "&"+alpha+";"); i++; continue; } } result += str.charAt(i); i++; } return result; }
Tests:
String concatentation
str = encodePlus('ga8f6c54agdsuhgdasuyidgaiuhdga<> dasdas &ga8f6c54agdsuhgdasuyidgaiuhdga<> dasdas &ga8f6c54agdsuhgdasuyidgaiuhdga<> dasdas &ga8f6c54agdsuhgdasuyidgaiuhdga<> dasdas &ga8f6c54agdsuhgdasuyidgaiuhdga<> dasdas &ga8f6c54agdsuhgdasuyidgaiuhdga<> dasdas &' + Date.now())
Array join (w/ push)
str = encodePush('ga8f6c54agdsuhgdasuyidgaiuhdga<> dasdas &ga8f6c54agdsuhgdasuyidgaiuhdga<> dasdas &ga8f6c54agdsuhgdasuyidgaiuhdga<> dasdas &ga8f6c54agdsuhgdasuyidgaiuhdga<> dasdas &ga8f6c54agdsuhgdasuyidgaiuhdga<> dasdas &ga8f6c54agdsuhgdasuyidgaiuhdga<> dasdas &' + Date.now())
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
String concatentation
Array join (w/ push)
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?