-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
benchmark: util._extend
vs object.assign
#7255
Conversation
To copy the values of all enumerable own properties from- a source object to a target object, node still use- `util._extend`, though newer standard `Object.assign` is available. This is because `util._extend` is found to be faster than `Object.assign`. This benchmark test is to keep track of how performance compare.
|
||
const bench = common.createBenchmark(main, { | ||
type: ['util._extend', 'Object.assign', | ||
'util._extend', 'Object.assign'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are there duplicates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
if (conf.type === 'extend') { | ||
fn = util._extend; | ||
v8command = '%OptimizeFunctionOnNextCall(util._extend)'; | ||
} else if (conf.type === 'assign') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: https://github.com/nodejs/node/blob/master/benchmark/common.js#L255
the benchmark/common.js now has a method for handling the details of v8 optimization for you. e.g.
function myMethod(a,b) {
/** ... **/
}
common.v8ForceOptimization(myMethod, 'a', 'b');
myMethod('a', 'b');
Couple of minor nits but LGTM if @mscdex is happy with it. |
v8command = '%OptimizeFunctionOnNextCall(util._extend)'; | ||
} else if (conf.type === 'assign') { | ||
fn = Object.assign; | ||
//Object.assign is built-in, cannot be optimized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space needed after //
.
One minor style nit, but otherwise LGTM |
fixed spacing nit.
Fixed the minor style. |
To copy the values of all enumerable own properties from- a source object to a target object, node still use- `util._extend`, though newer standard `Object.assign` is available. This is because `util._extend` is found to be faster than `Object.assign`. This benchmark test is to keep track of how performance compare. PR-URL: #7255 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]>
Landed in 6abb06f |
To copy the values of all enumerable own properties from- a source object to a target object, node still use- `util._extend`, though newer standard `Object.assign` is available. This is because `util._extend` is found to be faster than `Object.assign`. This benchmark test is to keep track of how performance compare. PR-URL: #7255 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]>
Checklist
make -j4 test
(UNIX) orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
benchmark
Description of change
To copy the values of all enumerable properties from-
a source object to a target object, node still use-
util._extend
, though newer standardObject.assign
is available. This is because
util._extend
is found tobe faster than
Object.assign
. This benchmark test isto keep track of how performance compare.