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>
function stringMultiply1(string, n) {
var temp = '';
for (var i = 0; i < n; i++)
temp += string;
return temp;
}
function stringMultiply2(string, n) {
var temp = string,
x = Math.floor(Math.log(n) / Math.LN2);
for (var i = 0; i < x; i++)
string += string;
for (var i = 0; i < (n - Math.pow(2, x)); i++)
string += temp;
return string;
}
function stringMultiply3(string, n) {
var x = Math.floor(Math.log(n) / Math.LN2),
temp = string;
for (var i = 0; i < x; i++)
string += string;
return (n) ? string + stringMultiply3(temp, n - Math.pow(2, x)) : "";
}
function stringMultiply4(str, num) {
var pre = [str],
b = num.toString(2).split('').reverse(),
l = b.length,
i = 1;
while (i < l) {
var s = pre[i - 1];
pre.push(s + s);
i++;
}
var i = 0;
while (i < l) {
if (b[i] == '0') pre[i] = '';
i++;
}
return pre.join('');
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
exponentiation + recursion |
| ready |
exponentiation + iteration |
| ready |
iteration |
| ready |
shit |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.