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
Comparing if it's faster to repeat a string using Array.join technique or a simple for loop.
<script>
String.prototype.repeatA = function(count) {
if (count < 1) return '';
var result = '', pattern = this.valueOf();
while (count > 0) {
if (count & 1) result += pattern;
count >>= 1, pattern += pattern;
};
return result;
};
String.prototype.repeatB = function(num) {
var i = 1,
result = this;
for (; i < num; ++i)
result += this;
return result;
}
var s1 = s2 = "helo",
r1 = r2 = "";
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
using fastest |
| ready |
Using simple for loop |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.