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 _map = (arr, fn) => {
const r = Array(arr.length)
for (let i = 0; i < arr.length; i++)r[i] = fn(arr[i])
return r
}
const bindClone = (fn, key) => {
let _fn = bindClone.dict.get(key);
if (_fn === undefined) {
_fn = fn.bind({})
bindClone.dict.set(key, _fn)
}
return _fn
};
bindClone.dict = new WeakMap()
const stringClone = (fn, key) => {
let _fn = stringClone.dict.get(key);
if (_fn === undefined) {
_fn = new Function(`return (${fn.toString()})`)()
stringClone.dict.set(key, _fn)
}
return _fn
};
stringClone.dict = new WeakMap()
const bindCloneMap = (arr, fn) => bindClone(_map, fn)(arr, fn)
const stringCloneMap = (arr, fn) => stringClone(_map, fn)(arr, fn)
const each1 = (i) => i + 1
const each2 = (i) => i + 2
const arr = new Array(1000).fill(true)
Ready to run.
Test | Ops/sec | |
---|---|---|
_map |
| ready |
bindCloneMap |
| ready |
stringCloneMap |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.