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
a silly test of palindrome testing techniques
<script>
function f1(str) {
return str === str.split('').reverse().join('');
}
function f2(str) {
for (var i=0; i<Math.floor(str.length / 2); i++) {
if (str.charAt(i) !== str.charAt(str.length-i-1)) return false;
}
return true;
}
function f3(str) {
return str.substring(0, Math.floor(str.length/2)) ==(str.substring(Math.ceil(str.length/2)).split('').reverse().join(''));
}
</script>
var str1 = "abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba";
var str2 = "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba";
var str3 = "abcdefghijklmnopqrstuvwxyzZyxwvutsrqponmlkjihgfedcba";
Ready to run.
Test | Ops/sec | |
---|---|---|
native strip reverse |
| ready |
for-loop character comparison |
| ready |
reverse half |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.