Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
util: faster arrayToHash#3964
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
util: faster arrayToHash #3964
Uh oh!
There was an error while loading. Please reload this page.
Conversation
thefourtheye commented Nov 22, 2015
Why not a |
JacksonTian commented Nov 22, 2015
The result of |
bnoordhuis commented Nov 22, 2015
LGTM but can you add a small benchmark in |
cjihrig commented Nov 22, 2015
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that avoiding accessing the length property each time will speed up it a little more.
varl=array.length;varval;vari;for(i=0;i<l;i++){val=array[i];hash[val]=true;}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V8 can speedup it with OSR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why make it do more work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using let here might have a more clear scope definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v8 is smart enough these days to cache the length automatically, so this shouldn't be an issue.
The `util.format()` is used frequently, make the method faster is better.
JacksonTian commented Nov 22, 2015
Benchmark is here: varutil=require('util');varcommon=require('../common.js');varbench=common.createBenchmark(main,{n: [5e6]});functionmain(conf){varn=conf.n|0;bench.start();for(vari=0;i<n;i+=1){varr=util.inspect({a: 'a',b: 'b',c: 'c',d: 'd'});}bench.end(n);}before: after: cc @bnoordhuis |
8b519cc to dc5bacbComparemscdex commented Nov 22, 2015
LGTM |
bnoordhuis commented Nov 22, 2015
Thanks, LGTM. CI: https://ci.nodejs.org/job/node-test-pull-request/810/ |
bnoordhuis commented Nov 23, 2015
Linking to nodejs/build#263. |
evanlucas commented Dec 1, 2015
Trying CI again https://ci.nodejs.org/job/node-test-pull-request/887/ |
JacksonTian commented Dec 14, 2015
What's wrong with CI? |
cjihrig commented Dec 14, 2015
Running CI again, just because it's been 2 weeks: https://ci.nodejs.org/job/node-test-pull-request/991/ |
trevnorris commented Dec 28, 2015
Anything holding this up? |
cjihrig commented Dec 29, 2015
I don't think so. Running CI again, then hopefully this can land. https://ci.nodejs.org/job/node-test-pull-request/1106/ |
jasnell commented Dec 30, 2015
LGTM |
jasnell commented Dec 30, 2015
Will get this landed. |
The `util.format()` is used frequently, make the method faster is better. R-URL: #3964 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: James M Snell <[email protected]>
jasnell commented Dec 30, 2015
Landed in 3e740ca |
jbergstroem commented Dec 31, 2015
Minor heads up, typo in commit message: |
jasnell commented Dec 31, 2015
Ugh. OK. Thanks for the heads up
|
The `util.format()` is used frequently, make the method faster is better. R-URL: nodejs#3964 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: James M Snell <[email protected]>
* http: - A new status code was added: 451 - "Unavailable For Legal Reasons" (Max Barinov) nodejs#4377 - Idle sockets that have been kept alive now handle errors (José F. Romaniello) nodejs#4482 * This release also includes several minor performance improvements: - assert: deepEqual is now speedier when comparing TypedArrays (Claudio Rodriguez) nodejs#4330 - lib: Use arrow functions instead of bind where possible (Minwoo Jung) nodejs#3622 - node: Improved accessor perf of process.env (Trevor Norris) nodejs#3780 - node: Improved performance of process.hrtime() (Trevor Norris) nodejs#3780, (Evan Lucas) nodejs#4484 - node: Improved GetActiveHandles performance (Trevor Norris) nodejs#3780 - util: Use faster iteration in util.format() (Jackson Tian) nodejs#3964 PR-URL: nodejs#4547
* http: - A new status code was added: 451 - "Unavailable For Legal Reasons" (Max Barinov) nodejs#4377 - Idle sockets that have been kept alive now handle errors (José F. Romaniello) nodejs#4482 * This release also includes several minor performance improvements: - assert: deepEqual is now speedier when comparing TypedArrays (Claudio Rodriguez) nodejs#4330 - lib: Use arrow functions instead of bind where possible (Minwoo Jung) nodejs#3622 - node: Improved accessor perf of process.env (Trevor Norris) nodejs#3780 - node: Improved performance of process.hrtime() (Trevor Norris) nodejs#3780, (Evan Lucas) nodejs#4484 - node: Improved GetActiveHandles performance (Trevor Norris) nodejs#3780 - util: Use faster iteration in util.format() (Jackson Tian) nodejs#3964 Refs: nodejs#4547 PR-URL: nodejs#4623 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
The `util.format()` is used frequently, make the method faster is better. R-URL: #3964 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: James M Snell <[email protected]>
The `util.format()` is used frequently, make the method faster is better. R-URL: #3964 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: James M Snell <[email protected]>
The `util.format()` is used frequently, make the method faster is better. R-URL: nodejs#3964 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: James M Snell <[email protected]>
* http: - A new status code was added: 451 - "Unavailable For Legal Reasons" (Max Barinov) nodejs#4377 - Idle sockets that have been kept alive now handle errors (José F. Romaniello) nodejs#4482 * This release also includes several minor performance improvements: - assert: deepEqual is now speedier when comparing TypedArrays (Claudio Rodriguez) nodejs#4330 - lib: Use arrow functions instead of bind where possible (Minwoo Jung) nodejs#3622 - node: Improved accessor perf of process.env (Trevor Norris) nodejs#3780 - node: Improved performance of process.hrtime() (Trevor Norris) nodejs#3780, (Evan Lucas) nodejs#4484 - node: Improved GetActiveHandles performance (Trevor Norris) nodejs#3780 - util: Use faster iteration in util.format() (Jackson Tian) nodejs#3964 Refs: nodejs#4547 PR-URL: nodejs#4623 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
The
util.format()is used frequently, make the method fasteris better.