Skip to content

Commit d85324c

Browse files
committed
profile progress
1 parent 996ea59 commit d85324c

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎bin/convert-argv.js‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,9 @@ module.exports = function(optimist, argv, convertOptions) {
213213
ifBooleanArg("progress", function() {
214214
var ProgressPlugin = require("../lib/ProgressPlugin");
215215
ensureArray(options, "plugins");
216-
var chars = 0;
216+
var chars = 0, lastState;
217217
options.plugins.push(new ProgressPlugin(function(percentage, msg) {
218+
var state = msg;
218219
if(percentage < 1) {
219220
percentage = Math.floor(percentage * 100);
220221
msg = percentage + "% " + msg;
@@ -226,6 +227,20 @@ module.exports = function(optimist, argv, convertOptions) {
226227
chars = msg.length;
227228
for(var i = 0; i < chars; i++)
228229
process.stderr.write("\b");
230+
if(options.profile) {
231+
state = state.replace(/^\d+\/\d+\s+/, "");
232+
if(percentage === 0) {
233+
lastState = null;
234+
lastStateTime = +new Date();
235+
} else if(state !== lastState || percentage === 1) {
236+
var now = +new Date();
237+
if(lastState) {
238+
process.stderr.write((now - lastStateTime) + "ms " + lastState + "\n");
239+
}
240+
lastState = state;
241+
lastStateTime = now;
242+
}
243+
}
229244
process.stderr.write(msg);
230245
}));
231246
});

‎lib/ProgressPlugin.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ ProgressPlugin.prototype.apply = function(compiler) {
3030
update();
3131
});
3232
compilation.plugin("optimize", function() {
33-
handler(0.75, "optimize");
33+
handler(0.73, "optimize");
34+
});
35+
compilation.plugin("before-hash", function() {
36+
handler(0.75, "hashing");
37+
});
38+
compilation.plugin("additional-chunk-assets", function() {
39+
handler(0.78, "additional chunk assets");
3440
});
3541
compilation.plugin("optimize-chunk-assets", function(chunks, callback) {
3642
handler(0.8, "optimize chunk assets");

0 commit comments

Comments
 (0)