Skip to content
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

Real world benchmark: saving ~150ms for Hygen #39

Closed
jondot opened this issue Nov 11, 2018 · 3 comments
Closed

Real world benchmark: saving ~150ms for Hygen #39

jondot opened this issue Nov 11, 2018 · 3 comments

Comments

@jondot
Copy link

jondot commented Nov 11, 2018

Hi all,
Hygen is next-gen code generation framework where one of the key principles is performance and developer experience.

Just wanted to FYI that in a real world replacement of inquirer with enquirer in Hygen (not pushed yet, but currently under testing) enquirer is winning ~150ms:

Before

Start time: (2018-11-11 08:13:51 UTC) [treshold=1%]
 #  module                                         time  %
 1  graceful-fs (node_mod...l-fs/graceful-fs.js)    4ms  ▇ 1%
 2  ./fs (node_modules/fs...tra/lib/fs/index.js)    4ms  ▇ 1%
 3  ./copy-sync (node_mod.../copy-sync/index.js)    3ms  ▇ 1%
 4  ./json (node_modules/...a/lib/json/index.js)    3ms  ▇ 1%
 5  fs-extra (node_module...-extra/lib/index.js)   20ms  ▇▇▇ 7%
 6  lodash (node_modules/lodash/lodash.js)         15ms  ▇▇▇ 5%
 7  yargs-parser (node_mo...rgs-parser/index.js)    3ms  ▇ 1%
 8  ./params (src/params.js)                       19ms  ▇▇▇ 7%
 9  ./engine (src/engine.js)                       40ms  ▇▇▇▇▇▇ 14%
10  color-convert (node_m...or-convert/index.js)    4ms  ▇ 1%
11  ansi-styles (node_mod...nsi-styles/index.js)    6ms  ▇ 2%
12  chalk (node_modules/chalk/index.js)             9ms  ▇▇ 3%
13  ./help (src/help.js)                            9ms  ▇▇ 3%
14  ./index (src/index.js)                         52ms  ▇▇▇▇▇▇▇▇ 18%
15  ./bin (src/bin.js)                             56ms  ▇▇▇▇▇▇▇▇▇ 19%
16  ./json (node_modules/...yaml/schema/json.js)    4ms  ▇ 1%
17  ./core (node_modules/...yaml/schema/core.js)    5ms  ▇ 2%
18  ./schema/default_safe...ema/default_safe.js)    9ms  ▇▇ 3%
19  esprima (node_modules...ima/dist/esprima.js)   14ms  ▇▇▇ 5%
20  ../type/js/function (...type/js/function.js)   15ms  ▇▇▇ 5%
21  ./schema/default_full...ema/default_full.js)   16ms  ▇▇▇ 5%
22  ./js-yaml/loader (nod...b/js-yaml/loader.js)   27ms  ▇▇▇▇▇ 9%
23  ./lib/js-yaml.js (nod...yaml/lib/js-yaml.js)   30ms  ▇▇▇▇▇ 10%
24  js-yaml (node_modules/js-yaml/index.js)        30ms  ▇▇▇▇▇ 10%
25  front-matter (node_mo...ont-matter/index.js)   31ms  ▇▇▇▇▇ 11%
26  ./context (src/context.js)                      3ms  ▇ 1%
27  ./render (src/render.js)                       36ms  ▇▇▇▇▇▇ 12%
28  chalk (node_modules/i...ules/chalk/index.js)    3ms  ▇ 1%
29  ./objects/separator (...bjects/separator.js)    4ms  ▇ 1%
30  lodash (node_modules/...es/lodash/lodash.js)   15ms  ▇▇▇ 5%
31  ./baseUI (node_module...er/lib/ui/baseUI.js)   17ms  ▇▇▇ 6%
32  ./ui/bottom-bar (node...ib/ui/bottom-bar.js)   19ms  ▇▇▇ 7%
33  ../Subscriber (node_m...ernal/Subscriber.js)    5ms  ▇ 2%
34  ./util/toSubscriber (...til/toSubscriber.js)    5ms  ▇ 2%
35  ./internal/Observable...ernal/Observable.js)    5ms  ▇ 2%
36  ./internal/observable...ctableObservable.js)    4ms  ▇ 1%
37  ./scheduler/queue (no.../scheduler/queue.js)    3ms  ▇ 1%
38  ../Notification (node...nal/Notification.js)    3ms  ▇ 1%
39  ./operators/observeOn...rators/observeOn.js)    3ms  ▇ 1%
40  ./internal/ReplaySubj...al/ReplaySubject.js)    7ms  ▇▇ 2%
41  ../util/subscribeToRe...ubscribeToResult.js)    3ms  ▇ 1%
42  ./internal/observable...le/combineLatest.js)    4ms  ▇ 1%
43  ./internal/observable...bservable/concat.js)    4ms  ▇ 1%
44  rxjs (node_modules/rxjs/index.js)              42ms  ▇▇▇▇▇▇▇ 14%
45  rxjs/operators (node_.../operators/index.js)   46ms  ▇▇▇▇▇▇▇ 16%
46  ./ui/prompt (node_mod...er/lib/ui/prompt.js)   91ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 31%
47  ../utils/screen-manag...s/screen-manager.js)    3ms  ▇ 1%
48  ./base (node_modules/...lib/prompts/base.js)    5ms  ▇ 2%
49  ./prompts/list (node_...lib/prompts/list.js)    9ms  ▇▇ 3%
50  chardet (node_modules/chardet/index.js)         4ms  ▇ 1%
51  iconv-lite (node_modu...v-lite/lib/index.js)    4ms  ▇ 1%
52  crypto (crypto)                                 4ms  ▇ 1%
53  tmp (node_modules/tmp/lib/tmp.js)               6ms  ▇ 2%
54  external-editor (node...ditor/main/index.js)   16ms  ▇▇▇ 5%
55  ./prompts/editor (nod...b/prompts/editor.js)   17ms  ▇▇▇ 6%
56  inquirer (node_module...rer/lib/inquirer.js)  144ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 49%
Total require(): 1034
Total time: 292ms

After

Start time: (2018-11-11 08:13:02 UTC) [treshold=1%]
 #  module                                        time  %
 1  ./polyfills.js (node_...ful-fs/polyfills.js)   2ms  ▇ 1%
 2  graceful-fs (node_mod...l-fs/graceful-fs.js)   4ms  ▇▇ 3%
 3  ./fs (node_modules/fs...tra/lib/fs/index.js)   5ms  ▇▇ 3%
 4  ../mkdirs (node_modul...lib/mkdirs/index.js)   6ms  ▇▇ 4%
 5  ./copy-sync (node_mod...y-sync/copy-sync.js)   8ms  ▇▇▇ 5%
 6  ./copy-sync (node_mod.../copy-sync/index.js)   8ms  ▇▇▇ 5%
 7  ./copy (node_modules/...ra/lib/copy/copy.js)   2ms  ▇ 1%
 8  ./copy (node_modules/...a/lib/copy/index.js)   2ms  ▇ 1%
 9  ../remove (node_modul...lib/remove/index.js)   2ms  ▇ 1%
10  ./empty (node_modules.../lib/empty/index.js)   2ms  ▇ 1%
11  ./ensure (node_module...lib/ensure/index.js)   2ms  ▇ 1%
12  ./json (node_modules/...a/lib/json/index.js)   2ms  ▇ 1%
13  fs-extra (node_module...-extra/lib/index.js)  26ms  ▇▇▇▇▇▇▇▇ 17%
14  lodash (node_modules/lodash/lodash.js)        16ms  ▇▇▇▇▇ 11%
15  ./params (src/params.js)                      18ms  ▇▇▇▇▇▇ 12%
16  ./engine (src/engine.js)                      45ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇ 30%
17  ./config-resolver (src/config-resolver.js)     2ms  ▇ 1%
18  ./conversions (node_m...vert/conversions.js)   2ms  ▇ 1%
19  color-convert (node_m...or-convert/index.js)   4ms  ▇▇ 3%
20  ansi-styles (node_mod...nsi-styles/index.js)   6ms  ▇▇ 4%
21  chalk (node_modules/chalk/index.js)            8ms  ▇▇▇ 5%
22  ./help (src/help.js)                           9ms  ▇▇▇ 6%
23  ./index (src/index.js)                        57ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 38%
24  ./bin (src/bin.js)                            61ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 40%
25  ./execute (src/execute.js)                     2ms  ▇ 1%
26  ejs (node_modules/ejs/lib/ejs.js)              2ms  ▇ 1%
27  ./json (node_modules/...yaml/schema/json.js)   4ms  ▇▇ 3%
28  ./core (node_modules/...yaml/schema/core.js)   4ms  ▇▇ 3%
29  ./schema/default_safe...ema/default_safe.js)   7ms  ▇▇▇ 5%
30  esprima (node_modules...ima/dist/esprima.js)  14ms  ▇▇▇▇▇ 9%
31  ../type/js/function (...type/js/function.js)  15ms  ▇▇▇▇▇ 10%
32  ./schema/default_full...ema/default_full.js)  16ms  ▇▇▇▇▇ 11%
33  ./js-yaml/loader (nod...b/js-yaml/loader.js)  25ms  ▇▇▇▇▇▇▇▇ 16%
34  ./js-yaml/dumper (nod...b/js-yaml/dumper.js)   2ms  ▇ 1%
35  ./lib/js-yaml.js (nod...yaml/lib/js-yaml.js)  28ms  ▇▇▇▇▇▇▇▇▇ 18%
36  js-yaml (node_modules/js-yaml/index.js)       28ms  ▇▇▇▇▇▇▇▇▇ 18%
37  front-matter (node_mo...ont-matter/index.js)  28ms  ▇▇▇▇▇▇▇▇▇ 18%
38  inflection (node_modu...n/lib/inflection.js)   2ms  ▇ 1%
39  ./context (src/context.js)                     3ms  ▇ 2%
40  ./render (src/render.js)                      34ms  ▇▇▇▇▇▇▇▇▇▇ 22%
41  ./add (src/ops/add.js)                         2ms  ▇ 1%
42  ./lib/utils (node_mod...quirer/lib/utils.js)   2ms  ▇ 1%
43  enquirer (node_modules/enquirer/index.js)      4ms  ▇▇ 3%
Total require(): 278
Total time: 152ms
@jondot
Copy link
Author

jondot commented Dec 28, 2018

Hygen 2.0.3 is now released with enquirer replacing inquirer (brew install hygen / yarn add hygen --dev)!

Here's some more eye candy:

Before:

$ time hygen

Error: please specify a generator.

Available actions:
init: self
hygen  0.15s user 0.08s system 100% cpu 0.230 total

After

$ time hygen

Error: please specify a generator.

Available actions:
init: self
hygen  0.10s user 0.03s system 102% cpu 0.122 total

@jonschlinkert
Copy link
Member

Closing, this will be referenced in the docs soon, thank you for letting us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants