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 value = "123";
const cache = new Map();
const prefixWithMap = (map, prefix, key) => {
let res = map.get(key);
if (typeof res === "string") return res;
res = `${prefix}${key}`;
map.set(key, res);
return res;
};
const createPrefixer = (prefix) => {
const cache = Object.create(null); // No prototype overhead
return (key) => {
return cache[key] ??= `${prefix}${key}`;
};
};
const prefixer = createPrefixer("prefix:");
const createPrefixProxy = (prefix) => {
const cache = Object.create(null);
return new Proxy({}, {
get(_, key) {
if (typeof key === 'string') {
return cache[key] ??= `${prefix}${key}`;
}
return undefined;
}
});
};
const prefixProxy = createPrefixProxy("prefix:");
Ready to run.
| Test | Ops/sec | |
|---|---|---|
| Template string | | ready |
| prefixWithMap | | ready |
| prefixer | | ready |
| prefixProxy | | ready |
| Classic | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.