Comparing performance of: Object.assign vs spread operator (v13)

Revision 13 of this benchmark created by Bhargav Krishna on


Test runner

Ready to run.

Testing in
TestOps/sec
create
var params = {
    "a": 2,
    "_id": "5c49a3f586a314e1da9bc5c4",
    "index": 0,
    "guid": "4a19223f-e806-4590-b0b2-bc52854010e9",
    "isActive": true,
    "balance": "$1,341.65",
    "picture": "http://placehold.it/32x32",
    "age": 33,
    "eyeColor": "brown",
    "name": "English Peck",
    "gender": "male",
    "company": "APPLIDECK",
    "email": "englishpeck@applideck.com",
    "phone": "+1 (995) 574-3187",
    "address": "479 Lloyd Court, Cecilia, District Of Columbia, 4378",
    "about": "Sunt laborum commodo ex nisi. Sint amet sit excepteur qui do veniam qui sint sit labore id. Laboris laborum amet eiusmod laborum duis.\r\n",
    "registered": "2017-02-11T03:09:56 -01:00",
    "latitude": 31.939115,
    "longitude": -54.305863,
    "tags": [
      "laborum",
      "laboris",
      "cupidatat",
      "nostrud",
      "dolore",
      "ex",
      "duis"
    ],
    "friends": [
      {
        "id": 0,
        "name": "Susie Sawyer"
      },
      {
        "id": 1,
        "name": "Lola Ware"
      },
      {
        "id": 2,
        "name": "Bender Barrera"
      }
    ],
    "greeting": "Hello, English Peck! You have 10 unread messages.",
    "favoriteFruit": "banana"
  };
ready
Object.assign
var params = {
    "_id": "5c49a3f586a314e1da9bc5c4",
    "index": 0,
    "guid": "4a19223f-e806-4590-b0b2-bc52854010e9",
    "isActive": true,
    "balance": "$1,341.65",
    "picture": "http://placehold.it/32x32",
    "age": 33,
    "eyeColor": "brown",
    "name": "English Peck",
    "gender": "male",
    "company": "APPLIDECK",
    "email": "englishpeck@applideck.com",
    "phone": "+1 (995) 574-3187",
    "address": "479 Lloyd Court, Cecilia, District Of Columbia, 4378",
    "about": "Sunt laborum commodo ex nisi. Sint amet sit excepteur qui do veniam qui sint sit labore id. Laboris laborum amet eiusmod laborum duis.\r\n",
    "registered": "2017-02-11T03:09:56 -01:00",
    "latitude": 31.939115,
    "longitude": -54.305863,
    "tags": [
      "laborum",
      "laboris",
      "cupidatat",
      "nostrud",
      "dolore",
      "ex",
      "duis"
    ],
    "friends": [
      {
        "id": 0,
        "name": "Susie Sawyer"
      },
      {
        "id": 1,
        "name": "Lola Ware"
      },
      {
        "id": 2,
        "name": "Bender Barrera"
      }
    ],
    "greeting": "Hello, English Peck! You have 10 unread messages.",
    "favoriteFruit": "banana"
  };
var other = Object.assign({}, { a: 2 }, params);
ready
spread
var params = {
    "_id": "5c49a3f586a314e1da9bc5c4",
    "index": 0,
    "guid": "4a19223f-e806-4590-b0b2-bc52854010e9",
    "isActive": true,
    "balance": "$1,341.65",
    "picture": "http://placehold.it/32x32",
    "age": 33,
    "eyeColor": "brown",
    "name": "English Peck",
    "gender": "male",
    "company": "APPLIDECK",
    "email": "englishpeck@applideck.com",
    "phone": "+1 (995) 574-3187",
    "address": "479 Lloyd Court, Cecilia, District Of Columbia, 4378",
    "about": "Sunt laborum commodo ex nisi. Sint amet sit excepteur qui do veniam qui sint sit labore id. Laboris laborum amet eiusmod laborum duis.\r\n",
    "registered": "2017-02-11T03:09:56 -01:00",
    "latitude": 31.939115,
    "longitude": -54.305863,
    "tags": [
      "laborum",
      "laboris",
      "cupidatat",
      "nostrud",
      "dolore",
      "ex",
      "duis"
    ],
    "friends": [
      {
        "id": 0,
        "name": "Susie Sawyer"
      },
      {
        "id": 1,
        "name": "Lola Ware"
      },
      {
        "id": 2,
        "name": "Bender Barrera"
      }
    ],
    "greeting": "Hello, English Peck! You have 10 unread messages.",
    "favoriteFruit": "banana"
  };
var other = { a: 2, ...params };
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 13: published by Bhargav Krishna on