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
How faster is object.assign polyfill versus jquery.extend vs deepExtend
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
var deepExtend = function(out) {
out = out || {};
for (var i = 1; i < arguments.length; i++) {
var obj = arguments[i];
if (!obj)
continue;
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === 'object')
deepExtend(out[key], obj[key]);
else
out[key] = obj[key];
}
}
}
return out;
};
function ToObject(val) {
if (val == null) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
var objectAssign = function (target, source) {
var pendingException;
var from;
var keys;
var to = ToObject(target);
for (var s = 1; s < arguments.length; s++) {
from = arguments[s];
keys = Object.keys(Object(from));
for (var i = 0; i < keys.length; i++) {
try {
to[keys[i]] = from[keys[i]];
} catch (err) {
if (pendingException === undefined) {
pendingException = err;
}
}
}
}
if (pendingException) {
throw pendingException;
}
return to;
};
var foo = {
"_id": "544a02b93024de7e94f2b552",
"index": 0,
"guid": "c681a251-2752-4f0f-b03c-71706472f455",
"isActive": true,
"balance": "$1,941.04",
"picture": "http://placehold.it/32x32",
"age": 20,
"eyeColor": "green",
"name": "Isabel Sutton",
"gender": "female",
"company": "APPLIDECK",
"email": "isabelsutton@applideck.com",
"phone": "+1 (818) 433-3007",
"agea": 20,
"eyeColora": "green",
"namea": "Washington Workman",
"gendera": "male",
"companya": "ASSURITY",
"emaila": "washingtonworkman@assurity.com",
"phonea": "+1 (985) 473-3253",
"address": "778 Harkness Avenue, Brambleton, South Carolina, 3955",
"about": "Fugiat quis id irure voluptate tempor amet do dolore exercitation aliqua nulla dolore pariatur ex. Anim irure incididunt amet officia. Deserunt consectetur qui et deserunt deserunt voluptate nulla consequat et ut aliqua anim elit. Cupidatat laboris anim aute tempor Lorem eu proident id ullamco veniam esse id ad. Reprehenderit irure enim quis minim est adipisicing ullamco officia consectetur cillum est voluptate duis.\r\n",
"registered": "2014-02-04T20:02:35 -02:00",
"latitude": 14.355911,
"longitude": 59.84098,
"tags": [
"sunt",
"magna",
"reprehenderit",
"velit",
"laborum",
"culpa",
"fugiat"
],
"friends": [
{
"id": 0,
"name": "Oneil Richmond",
"lastname": "<ReferenceError: lastName is not defined>"
},
{
"id": 1,
"name": "Monroe Rivers",
"lastname": "<ReferenceError: lastName is not defined>"
},
{
"id": 2,
"name": "Crystal Coffey",
"lastname": "<ReferenceError: lastName is not defined>"
}
],
"enemy": {
"id": 0,
"name": "Alisha Stewart"
},
"greeting": "Hello, Isabel Sutton! You have 5 unread messages.",
"favoriteFruit": "apple"
},
bar = {
"_id": "544a034cdd0bd1aa5541e760",
"index": 0,
"guid": "bb96d3b9-621d-4e49-8342-929266d44c9b",
"isActive": true,
"balance": "$1,011.14",
"picture": "http://placehold.it/32x32",
"age": 20,
"eyeColor": "brown",
"name": "Rosanne Benton",
"gender": "female",
"company": "GOLISTIC",
"email": "rosannebenton@golistic.com",
"phone": "+1 (931) 581-3997",
"agea": 20,
"eyeColora": "blue",
"namea": "Casey Vang",
"gendera": "female",
"companya": "NETAGY",
"emaila": "caseyvang@netagy.com",
"phonea": "+1 (930) 476-3149",
"address": "427 Amber Street, Greenbackville, Idaho, 8610",
"about": "Proident nisi ut elit sunt elit anim nisi esse. Aute exercitation quis aute officia sunt reprehenderit ipsum duis veniam eiusmod laboris. Quis quis laborum labore cillum esse voluptate.\r\n",
"registered": "2014-06-18T08:23:01 -03:00",
"latitude": -63.278754,
"longitude": 20.438224,
"tags": [
"officia",
"enim",
"proident",
"in",
"ut",
"consequat",
"proident"
],
"friends": [
{
"id": 0,
"name": "Stephanie Perkins"
},
{
"id": 1,
"name": "Ofelia Petty"
},
{
"id": 2,
"name": "Gould Murphy"
}
],
"enemy": {
"id": 0,
"name": "Eve Donaldson",
"lastName": "Porter"
},
"greeting": "Hello, Rosanne Benton! You have 1 unread messages.",
"favoriteFruit": "banana"
};
var foo = {
"_id": "544a02b93024de7e94f2b552",
"index": 0,
"guid": "c681a251-2752-4f0f-b03c-71706472f455",
"isActive": true,
"balance": "$1,941.04",
"picture": "http://placehold.it/32x32",
"age": 20,
"eyeColor": "green",
"name": "Isabel Sutton",
"gender": "female",
"company": "APPLIDECK",
"email": "isabelsutton@applideck.com",
"phone": "+1 (818) 433-3007",
"agea": 20,
"eyeColora": "green",
"namea": "Washington Workman",
"gendera": "male",
"companya": "ASSURITY",
"emaila": "washingtonworkman@assurity.com",
"phonea": "+1 (985) 473-3253",
"address": "778 Harkness Avenue, Brambleton, South Carolina, 3955",
"about": "Fugiat quis id irure voluptate tempor amet do dolore exercitation aliqua nulla dolore pariatur ex. Anim irure incididunt amet officia. Deserunt consectetur qui et deserunt deserunt voluptate nulla consequat et ut aliqua anim elit. Cupidatat laboris anim aute tempor Lorem eu proident id ullamco veniam esse id ad. Reprehenderit irure enim quis minim est adipisicing ullamco officia consectetur cillum est voluptate duis.\r\n",
"registered": "2014-02-04T20:02:35 -02:00",
"latitude": 14.355911,
"longitude": 59.84098,
"tags": [
"sunt",
"magna",
"reprehenderit",
"velit",
"laborum",
"culpa",
"fugiat"
],
"friends": [
{
"id": 0,
"name": "Oneil Richmond",
"lastname": "<ReferenceError: lastName is not defined>"
},
{
"id": 1,
"name": "Monroe Rivers",
"lastname": "<ReferenceError: lastName is not defined>"
},
{
"id": 2,
"name": "Crystal Coffey",
"lastname": "<ReferenceError: lastName is not defined>"
}
],
"enemy": {
"id": 0,
"name": "Alisha Stewart"
},
"greeting": "Hello, Isabel Sutton! You have 5 unread messages.",
"favoriteFruit": "apple"
},
bar = {
"_id": "544a034cdd0bd1aa5541e760",
"index": 0,
"guid": "bb96d3b9-621d-4e49-8342-929266d44c9b",
"isActive": true,
"balance": "$1,011.14",
"picture": "http://placehold.it/32x32",
"age": 20,
"eyeColor": "brown",
"name": "Rosanne Benton",
"gender": "female",
"company": "GOLISTIC",
"email": "rosannebenton@golistic.com",
"phone": "+1 (931) 581-3997",
"agea": 20,
"eyeColora": "blue",
"namea": "Casey Vang",
"gendera": "female",
"companya": "NETAGY",
"emaila": "caseyvang@netagy.com",
"phonea": "+1 (930) 476-3149",
"address": "427 Amber Street, Greenbackville, Idaho, 8610",
"about": "Proident nisi ut elit sunt elit anim nisi esse. Aute exercitation quis aute officia sunt reprehenderit ipsum duis veniam eiusmod laboris. Quis quis laborum labore cillum esse voluptate.\r\n",
"registered": "2014-06-18T08:23:01 -03:00",
"latitude": -63.278754,
"longitude": 20.438224,
"tags": [
"officia",
"enim",
"proident",
"in",
"ut",
"consequat",
"proident"
],
"friends": [
{
"id": 0,
"name": "Stephanie Perkins"
},
{
"id": 1,
"name": "Ofelia Petty"
},
{
"id": 2,
"name": "Gould Murphy"
}
],
"enemy": {
"id": 0,
"name": "Eve Donaldson",
"lastName": "Porter"
},
"greeting": "Hello, Rosanne Benton! You have 1 unread messages.",
"favoriteFruit": "banana"
};
Ready to run.
Test | Ops/sec | |
---|---|---|
jQuery.extend |
| ready |
deepLink |
| ready |
Object.assign poly fill |
| ready |
Object.assign |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.