Skip to content

Benchmark test between Object.Assign method and a custom Hiroki internal function

Notifications You must be signed in to change notification settings

ivanhuay/micron-object-assign

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Micron Benchmark Object Assign vs Hiroki Assign

This is a benchmark for analize posible performance issues with a Hiroki internal method.

Motivation

In this benchmark we measure the time of this custom assign function:

function assign(obj, set) {
    Object.keys(set).forEach((key) => {
        if(set[key].hasOwnProperty('$pull')) {
            obj[key] = obj[key].filter((subitem) => set[key].$pull.indexOf(subitem) === -1);
        } else if(set[key].hasOwnProperty('$push')) {
            obj[key] = obj[key].concat(set[key].$push);
        } else{
            obj[key] = set[key];
        }
    });
}

this function will be used to add the $pull and $push methods from update to a simple save method.

Also save and update has difference performace, you can check this difference here.

Results

Using that function with the $push is the worst performance with 3x times than just doing a Object.Assign but the times are equal to small for consider that a problem. We have to make 90000 perations to see a diference of 20ms.

view results HERE Alt image

Conclusion

Using this custom function will not significantly affect the performance of Hiroki.

run the test

git clone https://github.com/ivanhuay/micron-object-assign.git

cd micron-object-assign

npm i

npm run test

after running that the results should be on the docs folder.

About

Benchmark test between Object.Assign method and a custom Hiroki internal function

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published