Script Preparation code:
x
 
var voucher = {
    "single": false,
    "applyOverTaxes": false,
    "discountType": "1",
    "value": 100,
    "minimumAmount": 0,
    "quantity": 1,
    "suffixLength": 8,
    "code": "IF5R0AFX",
    "vertical": [],
    "allowedPaymentMethods": [],
    "allowedBanks": [],
    "types": [],
    "partners": [],
    "startDate": "2020-10-21T00:00:00.000Z",
    "endDate": "2020-10-21T00:00:00.000Z",
    "applyed": false
}
var voucherQuantityAndPriceUpdated = {
    value: 120,
    quantity: 10
}
Tests:
  • Using Object keys and modifying the original object

     
    const keysOfObjectWithUpdatedData = Object.keys(voucherQuantityAndPriceUpdated)
    for (key of keysOfObjectWithUpdatedData) {
        const updatedPropertyValue = 
        voucher[key] = voucherQuantityAndPriceUpdated[key]
    }
  • Using spread to merge objects

     
    const voucherUpdated = {
        ...voucher,
        ...voucherQuantityAndPriceUpdated
    }
  • Manually editing every single property (Wanna have this to prove why sometimes there is a manual assign for each property required)

     
    voucher.value = voucherQuantityAndPriceUpdated.value
    voucher.quantity = voucherQuantityAndPriceUpdated.quantity
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Using Object keys and modifying the original object
    Using spread to merge objects
    Manually editing every single property (Wanna have this to prove why sometimes there is a manual assign for each property required)

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Android 10; Mobile; rv:109.0) Gecko/112.0 Firefox/112.0
Firefox Mobile 112 on Android
View result in a separate tab
Test name Executions per second
Using Object keys and modifying the original object 3548374.0 Ops/sec
Using spread to merge objects 734079.1 Ops/sec
Manually editing every single property (Wanna have this to prove why sometimes there is a manual assign for each property required) 155488528.0 Ops/sec