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
<script>
// generate a random 20 character string
var str = (function () {
var str = '';
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",
rnum;
for (var i = 0; i < 100; i++) {
rnum = Math.floor(Math.random() * 61);
str += chars.substring(rnum, rnum + 1);
}
return str;
}());
function reverse_0 (str) {
var newStr = [];
str = str.split();
while(str.length) {
newStr.push(str.shift());
}
return newStr.join('');
}
function reverse_1 (str) {
var newStr = '';
for (var i = str.length - 1; i >= 0; i--) {
newStr += str[i];
}
return newStr;
}
function reverse_2 (str) {return str.split('').reverse().join('');}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
reverse_0 |
| ready |
reverse_1 |
| ready |
reverse_2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.