import { type ActionTrackConfigs, type MeasureCtxOptions, type MeasureOptions } from '../user-timing-extensibility-api-utils.js'; import type { ActionTrackEntryPayload, DevToolsColor, EntryMeta } from '../user-timing-extensibility-api.type.js'; /** * Generates a unique profiler ID based on performance time origin, process ID, thread ID, and instance count. */ export declare function getProfilerId(): string; /** * Configuration options for creating a Profiler instance. * * @template T - Record type defining available track names and their configurations */ type ProfilerMeasureOptions = MeasureCtxOptions & { /** Custom track configurations that will be merged with default settings */ tracks?: Record>; /** Whether profiling should be enabled (defaults to CP_PROFILING env var) */ enabled?: boolean; }; /** * Options for creating a performance marker. */ export type MarkerOptions = EntryMeta & { color?: DevToolsColor; }; /** * Options for configuring a Profiler instance. * * This is an alias for ProfilerMeasureOptions for backward compatibility. * * @template T - Record type defining available track names and their configurations * * @property enabled - Whether profiling is enabled (defaults to CP_PROFILING env var) * @property prefix - Prefix for all measurement names * @property track - Default track name for measurements * @property trackGroup - Default track group for organization * @property color - Default color for track entries * @property tracks - Custom track configurations merged with defaults */ export type ProfilerOptions = ProfilerMeasureOptions; /** * Performance profiler that creates structured timing measurements with Chrome DevTools Extensibility API payloads. * * This class provides high-level APIs for performance monitoring focused on Chrome DevTools Extensibility API data. * It supports both synchronous and asynchronous operations with all having smart defaults for custom track data. * */ export declare class Profiler { #private; static instanceCount: number; readonly id: string; readonly tracks: Record | undefined; /** * Creates a new Profiler instance with the specified configuration. * * @param options - Configuration options for the profiler * @param options.tracks - Custom track configurations merged with defaults * @param options.prefix - Prefix for all measurement names * @param options.track - Default track name for measurements * @param options.trackGroup - Default track group for organization * @param options.color - Default color for track entries * @param options.enabled - Whether profiling is enabled (defaults to CP_PROFILING env var) * */ constructor(options: ProfilerOptions); /** * Sets enabled state for this profiler. * * Also sets the `CP_PROFILING` environment variable. * This means any future {@link Profiler} instantiations (including child processes) will use the same enabled state. * * @param enabled - Whether profiling should be enabled */ setEnabled(enabled: boolean): void; /** * Is profiling enabled? * * Profiling is enabled by {@link setEnabled} call or `CP_PROFILING` environment variable. * * @returns Whether profiling is currently enabled */ isEnabled(): boolean; /** * Creates a performance mark including payload for a Chrome DevTools 'marker' item. * * Markers appear as vertical lines spanning all tracks and can include custom metadata * for debugging and performance analysis. When profiling is disabled, this method * returns immediately without creating any performance entries. * * @param name - Unique name for the marker * @param opt - Metadata and styling for the marker * @param opt.color - Color of the marker line (defaults to profiler default) * @param opt.tooltipText - Text shown on hover * @param opt.properties - Key-value pairs for detailed view show on click * * @example * profiler.marker('user-action-start', { * color: 'primary', * tooltipText: 'User clicked save button', * properties: [ * ['action', 'save'], * ['elementId', 'save-btn'] * ] * }); */ marker(name: string, opt?: MarkerOptions): void; /** * Measures the execution time of a synchronous operation. * * For asynchronous operations, use the {@link measureAsync} method. * * Creates performance start/end marks and a final measure. * All entries have Chrome DevTools Extensibility API payload and are visualized under custom tracks. * When profiling is disabled, executes the work function directly without overhead. * * @template R - The return type of the work function * @param event - Name for this measurement event * @param work - Function to execute and measure * @param options - Measurement configuration overrides * @returns The result of the work function * */ measure(event: string, work: () => R, options?: MeasureOptions): R; /** * Measures the execution time of an asynchronous operation. * * For synchronous operations, use the {@link measure} method. * * Creates performance start/end marks and a final measure. * All entries have Chrome DevTools Extensibility API payload and are visualized under custom tracks. * When profiling is disabled, executes and awaits the work function directly without overhead. * * @template R - The resolved type of the work promise * @param event - Name for this measurement event * @param work - Function returning a promise to execute and measure * @param options - Measurement configuration overrides * @returns Promise that resolves to the result of the work function * */ measureAsync(event: string, work: () => Promise, options?: MeasureOptions): Promise; } export {};