FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

benchmark: `util._extend` vs `object.assign` by suryagh · Pull Request #7255 · nodejs/node · GitHub

/ node Public

benchmark: util._extend vs object.assign - #7255

Closed
suryagh wants to merge 4 commits into
nodejs:masterfrom
suryagh:bmark1
Closed

benchmark: util._extend vs object.assign#7255
suryagh wants to merge 4 commits into
nodejs:masterfrom
suryagh:bmark1

Conversation

suryagh commented Jun 10, 2016

Copy link
Copy Markdown
Contributor
Checklist
  • make -j4 test (UNIX) or vcbuild test nosign (Windows) passes
  • a test and/or benchmark is included
  • the commit message follows commit guidelines
Affected 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 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.

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.
nodejs-github-bot added the benchmark Issues and PRs related to the benchmark subsystem. label Jun 10, 2016
mscdex added util Issues and PRs related to the built-in util module. v8 engine Issues and PRs related to the V8 dependency. labels Jun 10, 2016

const bench = common.createBenchmark(main, {
type: ['util._extend', 'Object.assign',
'util._extend', 'Object.assign'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why are there duplicates?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Removed.

if (conf.type === 'extend') {
fn = util._extend;
v8command = '%OptimizeFunctionOnNextCall(util._extend)';
} else if (conf.type === 'assign') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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');

jasnell commented Jun 20, 2016

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Space needed after //.

mscdex commented Jun 20, 2016

Copy link
Copy Markdown
Contributor

One minor style nit, but otherwise LGTM

suryagh commented Jun 20, 2016

Copy link
Copy Markdown
Contributor Author

Fixed the minor style.

jasnell pushed a commit that referenced this pull request Jun 27, 2016
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 <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>

jasnell commented Jun 27, 2016

Copy link
Copy Markdown
Member

Landed in 6abb06f

jasnell closed this Jun 27, 2016
Fishrock123 pushed a commit that referenced this pull request Jul 5, 2016
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 <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Fishrock123 mentioned this pull request Jul 5, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

benchmark Issues and PRs related to the benchmark subsystem. util Issues and PRs related to the built-in util module. v8 engine Issues and PRs related to the V8 dependency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL