chalk/chalk








The issue has been solved
Improve require speed #180
shnhrrsn posted onGitHub
I 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.
Fund this Issue
Rewarded pull request
Improve require speed #358submitted bystroncium(1,114)
Click to copy link
Recent activities