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 FunctionA(object) {
if("a" in object) {
return object.a;
}
return 12;
}
function FunctionB(object) {
if("a" in object) {
return object.a;
}
return 12;
}
function FunctionC(object) {
if("a" in object) {
return object.a;
}
return 12;
}
function FunctionD(object) {
if("a" in object) {
return object.a;
}
return 12;
}
GoodTestObjects = [
{a: 1},
{a: 2},
{a: 3},
{a: 4},
{a: 5}
]
BadTestObjects = [
{a: 1},
{a: 2, b: 3},
{a: 3, c: 4},
{a: 4, d: 5},
{a: 5, e: 6}
];
// Contaimate FunctionC.
let sum = 0;
for(let j = 0; j < 3; j++) {
for(let i = 0; i < BadTestObjects.length; i++) {
let value = BadTestObjects[i];
sum += FunctionC(value);
}
}
TrueSum = sum;Ready to run.
| Test | Ops/sec | |
|---|---|---|
| Good | | ready |
| Bad | | ready |
| Ok, but what if someone else passed in bad data earlier? | | ready |
| What if it's already optimized and we pass in some bad data? | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.