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>
function fib(x) {
if (x < 2) return 1;
else return fib(x - 1) + fib(x - 2);
}
// compact memoizer
function memoize1(param) {
this.memoize = this.memoize || {};
return (param in this.memoize) ? this.memoize[param] : this.memoize[param] = fib(param);
}
// using an external cache
var memCache = {};
function memoize2(param, cache) {
cache = cache || {};
return (param in cache) ? cache[param] : cache[param] = fib(param);
}
// stoyan's memoizer
function memoize3(param) {
if (!memoize3.cache) {
memoize3.cache = {};
}
if (!memoize3.cache[param]) {
var result = fib(param); //custom function
memoize3.cache[param] = result;
}
return memoize3.cache[param];
}
var m1,m2,m3 = 0;
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Compact memoize.js |
| ready |
Stoyan's version |
| ready |
With external cache |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.