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
var o = {
a: 'a',
b: 'b',
c: 'c',
d: 'd',
e: {
f: 'f',
g: 'g',
h: {
i: 'i',
j: 'j',
k: 'k',
l: 'l',
m: {
n: 'n',
o: {
p: 'p',
q: 'q',
r: 'r',
s: 's',
t: {
u: 'u',
v: 'v',
w: 'w',
x: 'x',
y: 'y'
}
}
}
}
},
z: {}
}, _o;
var clone = function (o) {
var _o = {}, p, value;
for (p in o) {
value = o[p];
if (value === Object.prototype[p]) continue;
_o[p] = value;
}
return _o;
};
var deepClone = function (o) {
var _o = {}, p, value;
for (p in o) {
value = o[p];
if (value === Object.prototype[p]) continue;
if (value && typeof value === "object")
_o[p] = deepClone(value);
else
_o[p] = value;
}
return _o;
};
var create;
create = function (o) {
return Object.create(o);
};
var fakeCreate = (function () {
var noop = function () {};
return function (o) {
noop.prototype = o;
return new noop();
};
})();
var deepCreate = function (o) {
var _o = Object.create(o), p, value;
for (p in _o) {
value = _o[p];
if (value && typeof value === "object")
_o[p] = deepCreate(value);
}
return _o;
};
var deepFakeCreate = function(o) {
var _o = fakeCreate(o), p, value;
for (p in _o) {
value = _o[p];
if (value && typeof value === "object")
_o[p] = deepFakeCreate(value);
}
return _o;
};
Ready to run.
Test | Ops/sec | |
---|---|---|
Shallow clone |
| ready |
Shallow Object.create |
| ready |
Deep clone |
| ready |
Deep create |
| ready |
Shallow fake create |
| ready |
Deep fake create |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.