Add option and scripts to display and compare performance timings - #2045
Conversation
b62a209 to
a60a21c
Compare
guybedford
left a comment
There was a problem hiding this comment.
Amazing work - this will be an awesome base to work on performance further!
| if (process.argv.length !== 3 || !VALID_REPO.test(repo)) { | ||
| console.error( | ||
| 'You need to provide a GitHub repo in the form <username>/<repo>, e.g. ' + | ||
| '"npm run perf:init rollup/rollup"' |
There was a problem hiding this comment.
Just thought I'd mention - it could be useful to support npm run perf:init rollup/rollup#branch-name where the branch becomes -b ${branchName} in the git clone when provided.
There was a problem hiding this comment.
Good idea! Even though the intention is to test is your current installation of rollup and not what you install in the perf folder, this feature could also be used to easily work on and debug rollup problems with branches in repos.
| .catch(error => { | ||
| console.error(error); | ||
| process.exit(1); | ||
| }); |
There was a problem hiding this comment.
This context could be a good excuse to use async/await...
|
|
||
| const TIME_RENDER_MODULES = '- render modules'; | ||
| const TIME_RENDER_FORMAT = '- render format'; | ||
| const TIME_SOURCEMAP = '- sourcemap'; |
There was a problem hiding this comment.
Perhaps have the names without the - and add this in the timers utility code rather?
|
|
||
| if (optionError) inputOptions.onwarn({ message: optionError, code: 'UNKNOWN_OPTION' }); | ||
| const TIME_BUILD = '# BUILD'; | ||
| const TIME_GENERATE = '# GENERATE'; |
There was a problem hiding this comment.
Ah I see you included the markers to distinguish hierarchy at this level.
Perhaps timeStart can take a second argument representing the heading number?
| await buildAndGetTimings(config); | ||
| console.info('Completed initial run (Discarded).'); | ||
| const timings = await buildAndGetTimings(config); | ||
| console.info('Completed run 1.'); |
There was a problem hiding this comment.
It could be useful to have some basic timing information as these show for quick perf testing when one doesn't want to wait for all the runs to complete (think eg ping).
|
I've been testing this out and there still appears to be quite a bit of variation in the timings. Perhaps run a manual GC call between runs to help avoid GC randomness? This can be done with |
|
@guybedford I have implemented all suggestions and did some further changes:
Maybe you want to have another look so that we can merge this soon. |
|
Looks great to me, please do go ahead with the merge. |
* Extract some constants * Improve scripts
* Display current (averaged) results after each run
17fcc07 to
bbd8289
Compare
|
@lukastaegert trying this out on Any clues? |
|
Nevermind, forgot to |
With the growing need to get reliable performance metrics, this PR aims to provide a comprehensive solution.
perf: true/falseoption. When this option is supplied, performance information is gathered and the bundle receives a newgetTimingsfunction that can be used to query all accumulated timings up to a certain pointperf: trueis used, in addition to timing rollup's own code, timing information will also gathered for most plugin hooks individually by plugin.perf: trueis used via the config file interface (or--perfvia the CLI), gathered timings will be displayed after the run. Timings are identified via labels that use a markdown-like syntax to receive some formatting.perf:initscript has been added to thepackage.jsonfile. This script receives a<Github username>/<repo name>or<Github username>/<repo name>#<branch>string as parameter to identify a repo that will be checked out into the/perffolder. The repo needs to contain arollup.config.jsfile at the top level (you can use e.g.rollup/rollup) and can be used as a base for performance measurements.perfscript has been added to thepackage.jsonfile. This script will use the current version of rollup in/distand use it via the JavaScript API to bundle the code in the/perffolder. If there are several configurations present, only the first input and output configuration is used./perf/rollup.perf.jsonis created to store the current measurements. If this file is already present, it will not be overwritten. Instead, deviations from the previous run will be displayed.Otherwise I think the best way to get a feeling for this, try it our yourself! Run
and see what happens.