fix(devtools): proper timing for operations

This commit is contained in:
mgechev
2020-02-20 12:13:31 -08:00
committed by Sumit Arora
parent 268ac30463
commit a8088ac68f
2 changed files with 8 additions and 7 deletions
@@ -29,7 +29,7 @@ export const start = (onFrame: (frame: ProfilerFrame) => void): void => {
runOutsideAngular(() => {
setTimeout(() => {
inChangeDetection = false;
onFrame(flushBuffer(observer, eventMap, getChangeDetectionSource()));
onFrame(flushBuffer(observer, getChangeDetectionSource()));
});
});
}
@@ -52,7 +52,7 @@ export const start = (onFrame: (frame: ProfilerFrame) => void): void => {
};
export const stop = (): ProfilerFrame => {
const result = flushBuffer(observer, eventMap);
const result = flushBuffer(observer);
// We want to garbage collect the records;
observer.destroy();
inProgress = false;
@@ -81,8 +81,8 @@ const insertElementProfile = (frames: ElementProfile[], position: ElementPositio
lastFrame.directives.push(profile);
};
const flushBuffer = (obs: ComponentTreeObserver, events: Map<any, DirectiveProfile>, source: string = '') => {
const items = Array.from(events.keys());
const flushBuffer = (obs: ComponentTreeObserver, source: string = '') => {
const items = Array.from(eventMap.keys());
const positions: ElementPosition[] = [];
const positionDirective = new Map<ElementPosition, any>();
items.forEach(dir => {
@@ -97,8 +97,9 @@ const flushBuffer = (obs: ComponentTreeObserver, events: Map<any, DirectiveProfi
};
positions.forEach(position => {
const dir = positionDirective.get(position);
insertElementProfile(result.directives, position, events.get(dir));
insertElementProfile(result.directives, position, eventMap.get(dir));
});
eventMap = new Map<any, DirectiveProfile>();
return result;
};
@@ -29,8 +29,8 @@ const getLabel = (element: ElementProfile) => {
const addFrame = (nodes: FlamegraphNode[], elements: ElementProfile[]): number => {
let timeSpent = 0;
elements.forEach(element => {
// Possibly undefined because of the insertion
// on the backend.
// Possibly undefined because of
// the insertion on the backend.
if (!element) {
return;
}