Uh oh!
There was an error while loading. Please reload this page.
console: refactor to use rest params and template strings - #6233
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 |
jasnell
commented
Apr 15, 2016
And you're right, they edge out template strings just a bit... but not by much. |
mscdex
commented
Apr 15, 2016
@jasnell There is only benchmarking of |
jasnell
commented
Apr 15, 2016
oh! misunderstood... I was referring to the concat in |
Fishrock123
commented
Apr 19, 2016
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. |
jasnell
commented
Apr 19, 2016
Why? I'm working in code already anyway (#6174). Is there a reason not to land this PR? |
Fishrock123
commented
Apr 19, 2016
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 ```
jasnell
commented
Apr 19, 2016
@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? |
mscdex
commented
Apr 20, 2016
What is the reason for using a stream in the benchmarks? |
jasnell
commented
Apr 20, 2016
@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. |
mscdex
commented
Apr 20, 2016
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>
jasnell
commented
Apr 20, 2016
Landed in 33c242e |
It appears that a lint error was accidentally committed to master. This fixes the issue. Refs: nodejs#6233
Trott
commented
Apr 20, 2016
Looks like this landed without running through CI. There's a linting error. Fix is in #6315 |
MylesBorins
commented
Apr 20, 2016
already fixed in cff2a13 |
jasnell
commented
Apr 20, 2016
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 |
jasnell
commented
Apr 20, 2016
@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 |
Trott
commented
Apr 21, 2016
@jasnell Not sure. People are supposed to run On the other hand, tools over rules and all that. |
jasnell
commented
Apr 21, 2016
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