Improve require speed
See original GitHub issueI tested this by creating a new project and adding just time-require and chalk. I then created a simple time.js
file with the following contents:
require('time-require')
require('chalk')
Results for Chalk 1.x (1.1.3 as of this posting):
Start time: (2017-07-22 16:50:03 UTC) [treshold=1%]
# module time %
1 pretty-ms (node_modules/pretty-ms/index.js) 1ms ββββββββ 11%
2 ansi-styles (node_modules/time-re...ules/ansi-styles/ansi-styles.js) 1ms ββββββββ 11%
3 has-color (node_modules/has-color/index.js) 1ms ββββββββ 11%
4 chalk (node_modules/time-require/node_modules/chalk/index.js) 3ms βββββββββββββββββββββββ 33%
5 escape-string-regexp (node_modules/escape-string-regexp/index.js) 1ms ββββββββ 11%
6 ansi-styles (node_modules/ansi-styles/index.js) 1ms ββββββββ 11%
7 has-ansi (node_modules/has-ansi/index.js) 1ms ββββββββ 11%
8 chalk (node_modules/chalk/index.js) 3ms βββββββββββββββββββββββ 33%
Total require(): 16
Total time: 9ms
Results for Chalk 2.x (2.0.1 as of this posting):
# module time %
1 text-table (node_modules/text-table/index.js) 1ms βββββ 6%
2 date-time (node_modules/date-time/index.js) 1ms βββββ 6%
3 parse-ms (node_modules/parse-ms/index.js) 1ms βββββ 6%
4 pretty-ms (node_modules/pretty-ms/index.js) 1ms βββββ 6%
5 ansi-styles (node_modules/time-re...ules/ansi-styles/ansi-styles.js) 1ms βββββ 6%
6 has-color (node_modules/has-color/index.js) 1ms βββββ 6%
7 chalk (node_modules/time-require/node_modules/chalk/index.js) 2ms βββββββββ 13%
8 escape-string-regexp (node_modules/escape-string-regexp/index.js) 1ms βββββ 6%
9 ./conversions (node_modules/color-convert/conversions.js) 2ms βββββββββ 13%
10 color-convert (node_modules/color-convert/index.js) 5ms ββββββββββββββββββββββ 31%
11 ansi-styles (node_modules/ansi-styles/index.js) 6ms ββββββββββββββββββββββββββ 38%
12 os (os) 1ms βββββ 6%
13 supports-color (node_modules/supports-color/index.js) 1ms βββββ 6%
14 ./templates.js (node_modules/chalk/templates.js) 1ms βββββ 6%
15 chalk (node_modules/chalk/index.js) 10ms βββββββββββββββββββββββββββββββββββββββββββ 63%
Total require(): 20
Total time: 16ms
I ran the tests several times locally and the results were all within 1ms each time.
For long running processes, the difference here is obviously negligible so Iβll understand if this gets closed out.
That being said, for CLI utils where boot time and responsiveness are far more important, itβs unfortunate that just using 2.x adds an additional 5ms+ on average that you canβt get back.
IssueHunt Summary
stroncium has been rewarded.
Backers (Total: $60.00)
- issuehunt ($60.00)
Submitted pull Requests
Tips
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on IssueHunt to raise funds.
IssueHunt has been backed by the following sponsors. Become a sponsor
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
9 Quick Ways to Improve Page Loading Speed - HubSpot Blog
Caching your web pages can help with lowering Time to First Byte (TTFB), by requiring the server to use fewer resources to load...
Read more >How to evaluate and improve page speed - Moz
By optimizing your code (including removing spaces, commas, and other unnecessary characters), you can dramatically increase your page speed.
Read more >THE 8 WAYS YOU CAN IMPROVE SPEED
THE 8 WAYS YOU CAN IMPROVE SPEED Β· 1. Improve Mobility Β· 2. Fix Asymmetries Β· 3. Build Core Stability Β· 4. Increase...
Read more >Tips to improve website speed | How to speed up websites
Slow website speed and performance can have major negative effects. Learn how to boost site speed, and get started by performing a website...
Read more >20 Ways to Speed Up Your Website and Improve Conversion ...
While all of these tips can help you improve your site speed, you don't need to do all of them today. In fact,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not sure what you suggest we do about this.
The community complains about many tiny modules, and then gets mad when X module doesnβt have all of these features out of the box. So weβve struck a somewhat bearable middleground by thinking really hard about every dependency we include.
@sindresorhus has rewarded $54.00 to @stroncium. See it on IssueHunt