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 src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>
function isBoolean(value) {
return typeof value === "boolean";
}
function random(min, max, float) {
switch(arguments.length) {
case 2:
if(isBoolean(max)) {
float = max;
}
else {
break;
}
/* falls through */
case 1:
max = min;
min = 0;
}
var result,
rand = Math.random();
if(!min && !max) {
return rand;
}
if(min % 1 !== 0 || max % 1 !== 0) {
float = true;
}
result = rand * (max - min) + min;
return float ? result : parseInt(result);
}
function shuffle(array) {
var index, randInt,
length = array.length,
result = new Array(length);
for(index = 0; index < length; ++index) {
randInt = parseInt(Math.random() * index);
if(index !== randInt) {
result[index] = result[randInt];
}
result[randInt] = array[index];
}
return result;
}
function shuffleRaw(array) {
var index, randInt,
length = array.length,
result = new Array(length);
for(index = 0; index < length; ++index) {
randInt = parseInt(random() * index);
if(index !== randInt) {
result[index] = result[randInt];
}
result[randInt] = array[index];
}
return result;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
lodash |
| ready |
custom |
| ready |
lodash shuffle |
| ready |
custom shuffle |
| ready |
custom shuffle raw |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.