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
// A function that may return null.
function rand() {
return Math.random()
}
function Option1() {
let n = rand();
if (n < 0.5) {
return null;
}
return n;
}
function Option2() {
let n = rand();
if (n < 0.5) {
return { t: 0, v: null }
}
return { t: 1, v: n }
}
function Option(n) {
this.t = 0;
this.v = n;
}
const None = new Option(0);
const Some = (v) => {
None.t = 1;
None.v = v;
return None;
}
function Option3() {
let n = rand();
if (n < 0.5) {
return None;
}
return Some(n);
}
const CachedSome = Some(0);
function Option4() {
let n = rand();
if (n < 0.5) {
CachedSome.v = n;
return CachedSome;
}
return None;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
null |
| ready |
Manual option |
| ready |
func opt |
| ready |
Cached Some |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.