mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Revert "refactor(core): let the profiler handle asymmetric events leniently"
This reverts commit da9911f2b4.
This commit is contained in:
parent
adc2a57be0
commit
88dfd96ec9
2 changed files with 8 additions and 31 deletions
|
|
@ -71,14 +71,14 @@ function measureEnd(
|
|||
entryName: string,
|
||||
color: DevToolsColor,
|
||||
) {
|
||||
let top: stackEntry | undefined;
|
||||
const top = eventsStack.pop();
|
||||
|
||||
// The stack may be asymmetric when an end event for a prior start event is missing (e.g. when an exception
|
||||
// has occurred), unroll the stack until a matching item has been found in that case.
|
||||
do {
|
||||
top = eventsStack.pop();
|
||||
assertDefined(top, 'Profiling error: could not find start event entry ' + startEvent);
|
||||
} while (top[0] !== startEvent);
|
||||
assertDefined(top, 'Profiling error: could not find start event entry ' + startEvent);
|
||||
assertEqual(
|
||||
top[0],
|
||||
startEvent,
|
||||
`Profiling error: expected to see ${startEvent} event but got ${top[0]}`,
|
||||
);
|
||||
|
||||
console.timeStamp(
|
||||
entryName,
|
||||
|
|
|
|||
|
|
@ -6,10 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {Component, HostAttributeToken, inject, Inject} from '../../src/core';
|
||||
import {enableProfiling} from '../../src/render3/debug/chrome_dev_tools_performance';
|
||||
import {profiler} from '../../src/render3/profiler';
|
||||
import {ProfilerEvent} from '../../src/render3/profiler_types';
|
||||
import {Component, HostAttributeToken, inject, Inject} from '../../src/core';
|
||||
import {TestBed} from '../../testing';
|
||||
|
||||
describe('Chrome DevTools Performance integration', () => {
|
||||
|
|
@ -61,26 +59,5 @@ describe('Chrome DevTools Performance integration', () => {
|
|||
stopProfiling();
|
||||
}
|
||||
});
|
||||
|
||||
it('should not crash when asymmetric events are processed', () => {
|
||||
const timeStampSpy = spyOn(console, 'timeStamp');
|
||||
const stopProfiling = enableProfiling();
|
||||
|
||||
try {
|
||||
profiler(ProfilerEvent.ChangeDetectionSyncStart);
|
||||
profiler(ProfilerEvent.ChangeDetectionStart);
|
||||
profiler(ProfilerEvent.ChangeDetectionSyncEnd);
|
||||
|
||||
const calls = timeStampSpy.calls.all();
|
||||
expect(calls.length).toBe(3);
|
||||
|
||||
const [syncStart, cdStart, syncEnd] = calls;
|
||||
expect(syncStart.args[0]).toMatch(/^Event_/);
|
||||
expect(cdStart.args[0]).toMatch(/^Event_/);
|
||||
expect(syncEnd.args[0]).toMatch(/^Synchronization /);
|
||||
} finally {
|
||||
stopProfiling();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue