-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
console: refactor to use rest params and template strings #6233
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
It would be nice to see manual string concatenation added to the benchmarks. I suspect that would be the "fastest" (at least compared to template strings the last I checked). |
It's there.. see https://github.com/nodejs/node/pull/6233/files#diff-32494b677ab738804f3e70d72fa804adR31 .. specifically, the |
And you're right, they edge out template strings just a bit... but not by much. |
@jasnell There is only benchmarking of |
oh! misunderstood... I was referring to the concat in |
It may be good to leave these (but not the benchmarks) for new contributors to deal with, since it's pretty easy to instruct people to change stuff to use es6. |
Why? I'm working in code already anyway (#6174). Is there a reason not to land this PR? |
I meant the type of changes, as exciting as it may be for us. I haven't checked this PR, but so long as perf is good we should be fine I suppose. |
Overall cleanup in code, eliminate reliance on `arguments`. Benchmarks show that as of v8 5.0.71.32, using rest params + apply has good performance. The spread operator is not yet well optimized in v8 ``` misc/console.js method=restAndSpread concat=1 n=1000000: 374779.38359 misc/console.js method=restAndSpread concat=0 n=1000000: 375988.30434 misc/console.js method=argumentsAndApply concat=1 n=1000000: 682618.61125 misc/console.js method=argumentsAndApply concat=0 n=1000000: 645093.74443 misc/console.js method=restAndApply concat=1 n=1000000: 682931.41217 misc/console.js method=restAndApply concat=0 n=1000000: 664473.09700 ```
@mscdex ... updated the benchmark to include a rest params + concat only example and you're right, it is the fastest approach, but not by a whole lot. Using rest params with apply, util.format and concat for the
|
@mscdex ... how does this look to you now? |
What is the reason for using a stream in the benchmarks? |
@mscdex ... because I didn't want to write out to console but still wanted to keep the scenario as close to console.log and console.warn as possible. |
LGTM |
Overall cleanup in code, eliminate reliance on `arguments`. Benchmarks show that as of v8 5.0.71.32, using rest params + apply has good performance. The spread operator is not yet well optimized in v8 ``` misc/console.js method=restAndSpread concat=1 n=1000000: 374779.38359 misc/console.js method=restAndSpread concat=0 n=1000000: 375988.30434 misc/console.js method=argumentsAndApply concat=1 n=1000000: 682618.61125 misc/console.js method=argumentsAndApply concat=0 n=1000000: 645093.74443 misc/console.js method=restAndApply concat=1 n=1000000: 682931.41217 misc/console.js method=restAndApply concat=0 n=1000000: 664473.09700 ``` PR-URL: #6233 Reviewed-By: Brian White <mscdex@mscdex.net>
Landed in 33c242e |
It appears that a lint error was accidentally committed to master. This fixes the issue. Refs: nodejs#6233
Looks like this landed without running through CI. There's a linting error. Fix is in #6315 |
already fixed in cff2a13 |
It appears I have a bug in my landing script :-/ ... sometimes it runs lint, other times it doesn't. Not quite sure why. Ah well, that's what I get for making the landing script overly complicated ;-) ... looks like I'm back to manual linting |
@Trott ... what would you think about a git pre-commit hook that enforces linting before commit? Obviously folks would have to install it locally to use it but having it available in tree would be worthwhile |
@jasnell Not sure. People are supposed to run On the other hand, tools over rules and all that. |
heh... well, I pulled the faulty make lint stuff out of my landing script and went back to the tried and true pre-push git hook. That'll teach me to get fancy with it. |
Overall cleanup in code, eliminate reliance on `arguments`. Benchmarks show that as of v8 5.0.71.32, using rest params + apply has good performance. The spread operator is not yet well optimized in v8 ``` misc/console.js method=restAndSpread concat=1 n=1000000: 374779.38359 misc/console.js method=restAndSpread concat=0 n=1000000: 375988.30434 misc/console.js method=argumentsAndApply concat=1 n=1000000: 682618.61125 misc/console.js method=argumentsAndApply concat=0 n=1000000: 645093.74443 misc/console.js method=restAndApply concat=1 n=1000000: 682931.41217 misc/console.js method=restAndApply concat=0 n=1000000: 664473.09700 ``` PR-URL: nodejs#6233 Reviewed-By: Brian White <mscdex@mscdex.net>
Overall cleanup in code, eliminate reliance on `arguments`. Benchmarks show that as of v8 5.0.71.32, using rest params + apply has good performance. The spread operator is not yet well optimized in v8 ``` misc/console.js method=restAndSpread concat=1 n=1000000: 374779.38359 misc/console.js method=restAndSpread concat=0 n=1000000: 375988.30434 misc/console.js method=argumentsAndApply concat=1 n=1000000: 682618.61125 misc/console.js method=argumentsAndApply concat=0 n=1000000: 645093.74443 misc/console.js method=restAndApply concat=1 n=1000000: 682931.41217 misc/console.js method=restAndApply concat=0 n=1000000: 664473.09700 ``` PR-URL: #6233 Reviewed-By: Brian White <mscdex@mscdex.net>
Rename test-fs-truncate-nodejsGH-6233 to test-fs-truncate-clear-file-zero Rename test-process-exit-nodejsGH-12322 to test-process-exit-flaky-handler Refs: nodejs#19105 Refs: https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md#test-structure
- Rename test-fs-truncate-GH-6233 to test-fs-truncate-clear-file-zero - Rename test-process-exit-GH-12322 to test-process-exit-handler PR-URL: #19668 Refs: #19105 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Rename test-fs-truncate-GH-6233 to test-fs-truncate-clear-file-zero - Rename test-process-exit-GH-12322 to test-process-exit-handler PR-URL: #19668 Refs: #19105 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Rename test-fs-truncate-GH-6233 to test-fs-truncate-clear-file-zero - Rename test-process-exit-GH-12322 to test-process-exit-handler PR-URL: #19668 Refs: #19105 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Checklist
Affected core subsystem(s)
console
Description of change
Overall cleanup in code, eliminate reliance on
arguments
.Benchmarks show that as of v8 5.0.71.32, using rest params + apply has good performance. The spread operator is not yet well optimized in v8