| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
`Object.assign` is built-in and has slight performance advantage- over the polyfill `_extend`. One thing to keep an eye is that `._extend` used to silently fails- while `assign` throws an error.
Do you have some benchmarks to back that up? That wasn't the case, as of #4593. |
Sorry, something went wrong.
|
Also see this similar PR that was submitted just the other week. |
Sorry, something went wrong.
|
I will close this pr in favour of any one of the similar earlier prs referenced here. However, would like to hear if anyone has any thoughts on the benchmark findings using the attached script. |
Sorry, something went wrong.
I think it was the nature of the data you were operating on. I switched to util._extend(extend, process.env); and Object.assign(extend, process.env); and saw a much bigger difference, in favor of util._extend(). $ ./node cji.js _extend took:: 186755.394ms oassign took:: 319979.233ms _extend took:: 200674.158ms oassign took:: 346792.866ms ^C It might be good to have a benchmark in the repo for this, since it keeps coming up. |
Sorry, something went wrong.
|
@cjihrig this is interesting. With your process.env approach, except the first iteration of the while loop, the source and destination objects are always similar structured objects. And in this case _extend() looks to be much faster. Seems optimizer (v8?) is able to detect this. |
Sorry, something went wrong.
|
@suryagh can I suggest opening a PR to create a benchmark for this? cc: @nodejs/benchmarking |
Sorry, something went wrong.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Checklist
Affected core subsystem(s)
http, tls, child-process, cluster, domain, fs, https, tty
Description of change
Object.assign is built-in and has some performance advantage-
over the polyfill.
One thing to keep an eye is that _extend used to fail silently-
while assign throws an error. Let me know if there are any concerns-
or if the pr need to be split based on the components.