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
Resolve path from string to object
function f00(path, value) {
const index = path.indexOf('.')
if (index < 0) return { [path]: value }
const splitted = path.split('.')
const last = splitted.length - 1
const obj = {}
let rel = obj;
for (let i = 0; i < last; ++i) {
rel = rel[splitted[i]] = {}
}
rel[splitted[last]] = value
return obj;
}
const m1 = {
'domain.name.uuid': (value) => ({domain:{name:{uuid:value}}}),
'domain.uuid': (value) => ({domain:{uuid:value}})
}
function f10(path, value) {
const index = path.indexOf('.')
if (index < 0) return { [path]: value }
return m1[path](value)
}
function f11(path, value) {
return path.indexOf('.') < 0 ? { [path]: value } : m1[path](value)
}
const m2 = {
'domain': (value) => ({domain:value}),
'user': (value) => ({user:value}),
'domain.name.uuid': (value) => ({domain:{name:{uuid:value}}}),
'domain.uuid': (value) => ({domain:{uuid:value}})
}
function f20(path, value) {
return m2[path](value)
}
function f21(path, value) {
const m21 = {
'domain': (value) => ({domain:value}),
'user': (value) => ({user:value}),
'domain.name.uuid': (value) => ({domain:{name:{uuid:value}}}),
'domain.uuid': (value) => ({domain:{uuid:value}})
}
return m21[path](value)
}
function f22(path, value) {
return {
'domain': (value) => ({domain:value}),
'user': (value) => ({user:value}),
'domain.name.uuid': (value) => ({domain:{name:{uuid:value}}}),
'domain.uuid': (value) => ({domain:{uuid:value}})
}[path](value)
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Function 00 (without map) |
| ready |
Function 10 (use partial map, long code) |
| ready |
Function 11 (use partial map, short code) |
| ready |
Function 20 (use full map, const global) |
| ready |
Function 21 (use full map, const local) |
| ready |
Function 22 (use full map, local) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.