refactor(ngcc): add debug logging for the duration of different operations (#32427)
This gives an overview of how much time is spent in each operation/phase and makes it easy to do rough comparisons of how different configurations or changes affect performance. PR Close #32427
This commit is contained in:

committed by
Matias Niemelä

parent
e36e6c85ef
commit
c714330856
@ -26,6 +26,7 @@ import {Deferred, sendMessageToWorker} from './utils';
|
||||
*/
|
||||
export class ClusterMaster {
|
||||
private finishedDeferred = new Deferred<void>();
|
||||
private processingStartTime: number = -1;
|
||||
private taskAssignments = new Map<number, Task|null>();
|
||||
private taskQueue: TaskQueue;
|
||||
|
||||
@ -67,6 +68,9 @@ export class ClusterMaster {
|
||||
|
||||
// First, check whether all tasks have been completed.
|
||||
if (this.taskQueue.allTasksCompleted) {
|
||||
const duration = Math.round((Date.now() - this.processingStartTime) / 1000);
|
||||
this.logger.debug(`Processed tasks in ${duration}s.`);
|
||||
|
||||
return this.finishedDeferred.resolve();
|
||||
}
|
||||
|
||||
@ -176,6 +180,11 @@ export class ClusterMaster {
|
||||
throw new Error(`Invariant violated: Worker #${workerId} came online more than once.`);
|
||||
}
|
||||
|
||||
if (this.processingStartTime === -1) {
|
||||
this.logger.debug('Processing tasks...');
|
||||
this.processingStartTime = Date.now();
|
||||
}
|
||||
|
||||
this.taskAssignments.set(workerId, null);
|
||||
this.maybeDistributeWork();
|
||||
}
|
||||
|
@ -27,11 +27,17 @@ export class SingleProcessExecutor implements Executor {
|
||||
createCompileFn((task, outcome) => onTaskCompleted(this.pkgJsonUpdater, task, outcome));
|
||||
|
||||
// Process all tasks.
|
||||
this.logger.debug('Processing tasks...');
|
||||
const startTime = Date.now();
|
||||
|
||||
while (!taskQueue.allTasksCompleted) {
|
||||
const task = taskQueue.getNextTask() !;
|
||||
compile(task);
|
||||
taskQueue.markTaskCompleted(task);
|
||||
}
|
||||
|
||||
const duration = Math.round((Date.now() - startTime) / 1000);
|
||||
this.logger.debug(`Processed tasks in ${duration}s.`);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user