mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
feat(core): expose performance data in Chrome DevTools (#60789)
This commit exposes the enableProfiling() function which enables performance data visualisation directly in the Chrome DevTools performance panel. PR Close #60789
This commit is contained in:
@@ -10,6 +10,9 @@ export function applyChanges(component: {}): void;
|
||||
// @public
|
||||
export type DirectiveDebugMetadata = AngularDirectiveDebugMetadata | AcxDirectiveDebugMetadata | AngularComponentDebugMetadata | AcxComponentDebugMetadata | WizComponentDebugMetadata;
|
||||
|
||||
// @public
|
||||
export function enableProfiling(): () => void;
|
||||
|
||||
// @public
|
||||
export function getComponent<T>(element: Element): T | null;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import {InjectionToken} from '../../di';
|
||||
import {isTypeProvider} from '../../di/provider_collection';
|
||||
import {assertDefined, assertEqual} from '../../util/assert';
|
||||
import {performanceMarkFeature} from '../../util/performance';
|
||||
import {setProfiler} from '../profiler';
|
||||
import {Profiler, ProfilerEvent} from '../profiler_types';
|
||||
import {stringifyForError} from '../util/stringify_utils';
|
||||
@@ -224,7 +225,19 @@ function getProviderTokenMeasureName<T>(token: any) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start listening to the Angular's internal performance-related events and route those to the Chrome DevTools performance panel.
|
||||
* This enables Angular-specific data visualization when recording a performance profile directly in the Chrome DevTools.
|
||||
*
|
||||
* @returns a function that can be invoked to stop sending profiling data.
|
||||
*/
|
||||
export function enableProfiling() {
|
||||
setInjectorProfiler(chromeDevToolsInjectorProfiler);
|
||||
setProfiler(devToolsProfiler);
|
||||
performanceMarkFeature('Chrome DevTools profiling');
|
||||
const removeInjectorProfiler = setInjectorProfiler(chromeDevToolsInjectorProfiler);
|
||||
const removeProfiler = setProfiler(devToolsProfiler);
|
||||
|
||||
return () => {
|
||||
removeInjectorProfiler();
|
||||
removeProfiler();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
export {applyChanges} from './util/change_detection_utils';
|
||||
export {enableProfiling} from './debug/chrome_dev_tools_performance';
|
||||
export {
|
||||
DirectiveDebugMetadata,
|
||||
getComponent,
|
||||
|
||||
@@ -33,6 +33,8 @@ import {
|
||||
} from './injector_discovery_utils';
|
||||
import {getSignalGraph} from './signal_debug';
|
||||
|
||||
import {enableProfiling} from '../debug/chrome_dev_tools_performance';
|
||||
|
||||
/**
|
||||
* This file introduces series of globally accessible debug tools
|
||||
* to allow for the Angular debugging story to function.
|
||||
@@ -82,6 +84,8 @@ const globalUtilsFunctions = {
|
||||
'getDirectives': getDirectives,
|
||||
'applyChanges': applyChanges,
|
||||
'isSignal': isSignal,
|
||||
|
||||
'enableProfiling': enableProfiling,
|
||||
};
|
||||
type CoreGlobalUtilsFunctions = keyof typeof globalUtilsFunctions;
|
||||
type ExternalGlobalUtilsFunctions = keyof NgGlobalPublishUtils;
|
||||
|
||||
Reference in New Issue
Block a user