jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
PLEASE RUN TEST ON MOBILE PHONES ONLY Different ways to concatenate strings together.
<script>
var str1 = "abcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefga";
var str2 = "abcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefg";
var str3 = "abcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefg";
var str4 = "abcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefg";
var arr = [str1, str2, str3, str4];
var concat = function (arr) {
var len = arr.length, s, i;
for (s = "", i = 0; i < len; s += arr[i], i++);
return s;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Direct concatenation |
| ready |
Individual += statements |
| ready |
Individual statements |
| ready |
Using Array#join |
| ready |
Single individual statement |
| ready |
Function based (for) |
| ready |
concat |
| ready |
direct concat |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.