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
const emptyArray = [];
const singleMemoMulti = (fn) => {
let lastArgs = emptyArray;
let lastResult;
return (...args) => {
if (lastArgs === emptyArray) {
lastArgs = args;
lastResult = fn(...args);
return lastResult;
}
for (let i = 0; i < args.length; i++) {
if (lastArgs[i] !== args[i]) {
lastResult = fn(...args);
lastArgs = args;
return lastResult;
}
}
return lastResult;
};
};
const run = singleMemoMulti((a, b, c, d, e, f, g) => {
})
const singleMemoMultiApply = (fn) => {
let lastArgs;
let lastResult;
return function() {
if (!lastArgs) {
lastArgs = arguments;
lastResult = fn.apply(null, arguments)
return lastResult;
}
for (let i = 0; i < arguments.length; i++) {
if (lastArgs[i] !== arguments[i]) {
lastResult = fn.apply(null, arguments);
lastArgs = arguments;
return lastResult;
}
}
return lastResult;
};
};
const runApply = singleMemoMultiApply((a, b, c, d, e, f, g) => {})
Ready to run.
| Test | Ops/sec | |
|---|---|---|
| singleMemoMulti | | ready |
| singleMemoMultiApply | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.