-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Edit: see #1145 (comment) for reproducible example
Hi. While fooling around with jspm I identified that while everything gets gradually slower when adding files, uglifyjs got way slower.
In particular its this (https://github.com/systemjs/builder/blob/master/lib/output.js#L84) figure_out_scope() call after ast.transform()
This is the repository with the test:
https://github.com/sod/jspm-rollup/tree/uglify-perf
npm install then bin/create-child-components.sh <n>; time bin/build.sh where <n> is the amount of files. These files become merged together by rollup and then minified by uglify-js.
bin/create-child-components.sh 1; time bin/build.sh # time: 11s, figure_out_scope(): 7s
bin/create-child-components.sh 100; time bin/build.sh # time: 18s, figure_out_scope(): 10s
bin/create-child-components.sh 200; time bin/build.sh # time: 26s, figure_out_scope(): 18s
bin/create-child-components.sh 300; time bin/build.sh # time: 41s, figure_out_scope(): 32s
bin/create-child-components.sh 400; time bin/build.sh # time: 65s, figure_out_scope(): 53s
bin/create-child-components.sh 500; time bin/build.sh # time: 90s, figure_out_scope(): 76s
bin/create-child-components.sh 600; time bin/build.sh # time: 122s, figure_out_scope(): 107s
from the first (11s) to the last (122s) the unminified bundle file only got around 30% bigger. I guess the timesink has something to do how rollup.js generates a single big function?
The part in the bundle that grows bigger with the bin create-child-components.sh looks like this:
https://gist.github.com/sod/c546667ca62cfcf6f696fc5b700719ec
It repeats every 18 lines of code, just increments some values.
you can generate a non minified file with node_modules/.bin/jspm build app dist/build.js --global-name myBundle --skip-source-maps into dist/build.js
OS X 10.11.5, node 6.2.1