Skip to content
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: use object literal shorthands #12194

Closed
wants to merge 1 commit into from
Closed

benchmark: use object literal shorthands #12194

wants to merge 1 commit into from

Conversation

vsemozhetbyt
Copy link
Contributor

Checklist
Affected core subsystem(s)

benchmark

For extra precaution, a benchmark to compare full and short notation is also added. It shows no significant degradation, if any could be with this change.

@nodejs-github-bot nodejs-github-bot added the benchmark Issues and PRs related to the benchmark subsystem. label Apr 3, 2017
@vsemozhetbyt
Copy link
Contributor Author

@lpinca
Copy link
Member

lpinca commented Apr 4, 2017

I'm not against this change but it adds little value imho.

@vsemozhetbyt
Copy link
Contributor Author

vsemozhetbyt commented Apr 4, 2017

@lpinca Well, I thought it increased readability and maintenanceability a little (decreased tautology, redundancy, syntactical noise). And I've started from benchmark to see how it goes. In tests there are much more cases, maybe hundreds. If it is worthless change, then I shall not start with tests.

@lpinca
Copy link
Member

lpinca commented Apr 4, 2017

@vsemozhetbyt wait for other collaborators opinions. Again, I'm not against these changes but in the past we avoided making purely cosmetic changes.

@vsemozhetbyt
Copy link
Contributor Author

FWIW, just some examples from tests with rewritten variants:

  const pair = {
    server: server,
    client: client,
  };
  const pair = { server, client };

  child = spawn('/usr/bin/env', [], {env: env});
  child = spawn('/usr/bin/env', [], { env });

      process.send({received: received});
      process.send({ received });

  result = fs.realpathSync(string_dir, {encoding: encoding});
  result = fs.realpathSync(string_dir, { encoding });

    const options = {
      port: port,
      host: host,
      rejectUnauthorized: false,
      _agentKey: agent.getName({
        port: port,
        host: host,
      }),
    };
    const options = {
      port,
      host,
      rejectUnauthorized: false,
      _agentKey: agent.getName({ port, host }),
    };

  const options = {
    port: port,
    path: path,
    ca: ca
  };
  const options = { port, path, ca };

@gibfahn
Copy link
Member

gibfahn commented Apr 4, 2017

I think the change improves readability, so +1 from me. Adding a benchmark is also good.

Don't really have the expertise to approve.

cc/ @nodejs/benchmarking @mscdex

Is @nodejs/benchmarking the team we should cc for performance things? I see them in onboarding-extras, but that doesn't include people I've seen be active in recent performance issues (like @mscdex and @joyeecheung).

@sam-github
Copy link
Contributor

I think examples like const options = { port, path, ca }; are nice, but that actual PR has a bunch of changes like:

{
  key: someValue,
  other: 9,
  blah,  // used to be blah: blah,
  someKey: 12
}

And that is not more readable, because it mixes syntax sugar and non-sugar in a single literal, so I have to shift my thinking back and forth. I'm not a fan of that.

@joyeecheung
Copy link
Member

@gibfahn I think the benchmarking team is more about https://benchmarking.nodejs.org/? (We could make another team for core-related issues tough, e.g. nodejs/performance...)

I am +0 on making function shorthands, but yeah mixing literal shorthands with normal key-value pairs is a bit confusing like what #12194 (comment) says.

@gibfahn gibfahn mentioned this pull request Apr 4, 2017
2 tasks
@jasnell
Copy link
Member

jasnell commented Apr 4, 2017

Historically, we have avoided modifying existing benchmarks too much to ensure that they still have a reasonable chance of running in older versions of Node.js. That said, I do not believe any of the suggested changes are problematic for Node.js 4.x and on.

@vsemozhetbyt
Copy link
Contributor Author

Maybe mixing { prop } and { prop: prop, prop2: something } is a bit confusing approach too.

Well, it seems to be a rather controversial change. I shall close for now. Thank you for the feedback)

@vsemozhetbyt vsemozhetbyt deleted the object-shorthands-benchmarks branch April 4, 2017 19:43
gibfahn added a commit to gibfahn/node that referenced this pull request Apr 8, 2017
Can be cc'ed with `@nodejs/performance`.

PR-URL: nodejs#12213
Refs: nodejs#12194 (comment)
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Apr 10, 2017
Can be cc'ed with `@nodejs/performance`.

PR-URL: nodejs#12213
Refs: nodejs#12194 (comment)
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 18, 2017
Can be cc'ed with `@nodejs/performance`.

PR-URL: #12213
Refs: #12194 (comment)
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 19, 2017
Can be cc'ed with `@nodejs/performance`.

PR-URL: #12213
Refs: #12194 (comment)
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
andrew749 pushed a commit to michielbaird/node that referenced this pull request Jul 19, 2017
Can be cc'ed with `@nodejs/performance`.

PR-URL: nodejs/node#12213
Refs: nodejs/node#12194 (comment)
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants