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
function randomStr(len) {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",schars="ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var str = '';
for (var i=0; i<len; i++) {
if(i==0)
{
var rnum = Math.floor(Math.random() * schars.length);
str += schars.substring(rnum,rnum+1);
}
else
{
var rnum = Math.floor(Math.random() * chars.length);
str += chars.substring(rnum,rnum+1);
}
}
return str;
}
function randomStr2(len) {
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
const schars="ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
let str = schars[Math.floor(Math.random() * schars.length)];
for (var i = 1; i < len; i++) {
str += chars[Math.floor(Math.random() * chars.length)];
}
return str;
}
Ready to run.
| Test | Ops/sec | |
|---|---|---|
| randomStr | | ready |
| randomStr2 | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.