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

discussion: eslint rule for /test/ - no-unused-vars: [error, {args: after-used, caughtErrors: all}] #14137

Closed
refack opened this issue Jul 8, 2017 · 3 comments
Labels
discuss Issues opened for discussions and feedbacks. performance Issues and PRs related to the performance of Node.js. test Issues and PRs related to the tests.

Comments

@refack
Copy link
Contributor

refack commented Jul 8, 2017

  • Version: *
  • Platform: *
  • Subsystem: test

There still seems to be a small performance advantage to using functors that match the signature of the invocation:

> var o = 0;
> function trig(a, b, f) { const x = f(a,b); o = x; };
> function trig2(b, a, f) { const x = f(a,b); o = x; };
> console.time('0'); for (let i = 0; i < 1e8; ++i) (i%2 ? trig : trig2)(i+1, i+2, () => i);console.timeEnd('0')
0: 7371.239ms
> console.time('a,b'); for (let i = 0; i < 1e8; ++i) (i%2 ? trig : trig2)(i+1, i+2, (a,b) => i);console.timeEnd('a,b')
a,b: 7066.650ms

For for explicitness sake, would we consider requiring no unused arguments (or exception) in /test/?
i.e.:

/* eslint no-unused-vars: [error, {args: after-used, caughtErrors: all }] */

// "baz" is defined but never used
(function(foo, bar, baz) {
    return bar;
})();

try {
  foo();
} catch (e) {
  // "e" is defined but never used
}

Current impact on /test/: 297 error in 195 files

/cc @nodejs/testing @nodejs/performance

@refack refack added discuss Issues opened for discussions and feedbacks. performance Issues and PRs related to the performance of Node.js. refactor to ES6+ test Issues and PRs related to the tests. labels Jul 8, 2017
@Trott
Copy link
Member

Trott commented Aug 5, 2017

Ref: #10129

@refack
Copy link
Contributor Author

refack commented Aug 9, 2017

Enough talk, time for action

@refack refack closed this as completed Aug 9, 2017
@refack
Copy link
Contributor Author

refack commented Aug 29, 2017

Update for TF&I, performance penalty is < 1%

> var o = 0;
> function trig(a, b, f) { const x = f(a,b); o = x; };
> function trig2(b, a, f) { const x = f(a,b); o = x; };
> console.time('0'); for (let i = 0; i < 1e8; ++i) (i%2 ? trig : trig2)(i+1, i+2, () => i);console.timeEnd('0')
0: 2449.016ms
> console.time('a,b'); for (let i = 0; i < 1e8; ++i) (i%2 ? trig : trig2)(i+1, i+2, (a,b) => i);console.timeEnd('a,b')
a,b: 2421.129ms
> console.time('0'); for (let i = 0; i < 1e9; ++i) (i%2 ? trig : trig2)(i+1, i+2, () => i);console.timeEnd('0')
0: 24336.730ms
> console.time('a,b'); for (let i = 0; i < 1e9; ++i) (i%2 ? trig : trig2)(i+1, i+2, (a,b) => i);console.timeEnd('a,b')
a,b: 24299.949ms
> process.version
'v8.4.0'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Issues opened for discussions and feedbacks. performance Issues and PRs related to the performance of Node.js. test Issues and PRs related to the tests.
Projects
None yet
Development

No branches or pull requests

2 participants