Skip to content

Commit 2e51747

Browse files
committed
refactor: wip
1 parent 64457f3 commit 2e51747

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

packages/utils/src/lib/profiler/profiler.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ type ProfilerMeasureOptions<T extends Record<string, ActionTrackEntryPayload>> =
3434
* This is an alias for ProfilerMeasureOptions for backward compatibility.
3535
*
3636
* @template T - Record type defining available track names and their configurations
37+
*
38+
* @property enabled - Whether profiling is enabled (defaults to CP_PROFILING env var)
39+
* @property prefix - Prefix for all measurement names
40+
* @property track - Default track name for measurements
41+
* @property trackGroup - Default track group for organization
42+
* @property color - Default color for track entries
43+
* @property tracks - Custom track configurations merged with defaults
3744
*/
3845
export type ProfilerOptions<
3946
T extends Record<string, ActionTrackEntryPayload> = Record<
@@ -43,11 +50,10 @@ export type ProfilerOptions<
4350
> = ProfilerMeasureOptions<T>;
4451

4552
/**
46-
* Performance profiler that creates structured timing measurements with DevTools visualization.
53+
* Performance profiler that creates structured timing measurements with Chrome DevTools Extensibility API payloads.
4754
*
48-
* This class provides high-level APIs for performance monitoring with automatic DevTools
49-
* integration for Chrome DevTools Performance panel. It supports both synchronous and
50-
* asynchronous operations with customizable track visualization.
55+
* This class provides high-level APIs for performance monitoring focused on Chrome DevTools Extensibility API data.
56+
* It supports both synchronous and asynchronous operations with all having smart defaults for custom track data.
5157
*
5258
*/
5359
export class Profiler<T extends Record<string, ActionTrackEntryPayload>> {
@@ -109,7 +115,7 @@ export class Profiler<T extends Record<string, ActionTrackEntryPayload>> {
109115
}
110116

111117
/**
112-
* Creates a performance marker in the DevTools Performance panel.
118+
* Creates a performance mark including payload for a Chrome DevTools 'marker' item.
113119
*
114120
* Markers appear as vertical lines spanning all tracks and can include custom metadata
115121
* for debugging and performance analysis. When profiling is disabled, this method
@@ -119,7 +125,7 @@ export class Profiler<T extends Record<string, ActionTrackEntryPayload>> {
119125
* @param opt - Metadata and styling for the marker
120126
* @param opt.color - Color of the marker line (defaults to profiler default)
121127
* @param opt.tooltipText - Text shown on hover
122-
* @param opt.properties - Key-value pairs for detailed view
128+
* @param opt.properties - Key-value pairs for detailed view show on click
123129
*
124130
* @example
125131
* profiler.marker('user-action-start', {
@@ -140,7 +146,7 @@ export class Profiler<T extends Record<string, ActionTrackEntryPayload>> {
140146
name,
141147
asOptions(
142148
markerPayload({
143-
// marker only supports color no TrackMeta
149+
// marker only takes default color, no TrackMeta
144150
...(this.defaults.color ? { color: this.defaults.color } : {}),
145151
...opt,
146152
}),
@@ -151,8 +157,8 @@ export class Profiler<T extends Record<string, ActionTrackEntryPayload>> {
151157
/**
152158
* Measures the execution time of a synchronous operation.
153159
*
154-
* Creates start/end marks and a final measure entry in the performance timeline.
155-
* The operation appears in the configured track with proper DevTools visualization.
160+
* Creates performance start/end marks and a final measure.
161+
* All entries have Chrome DevTools Extensibility API payload and are visualized under custom tracks.
156162
* When profiling is disabled, executes the work function directly without overhead.
157163
*
158164
* @template R - The return type of the work function
@@ -185,8 +191,8 @@ export class Profiler<T extends Record<string, ActionTrackEntryPayload>> {
185191
/**
186192
* Measures the execution time of an asynchronous operation.
187193
*
188-
* Creates start/end marks and a final measure entry in the performance timeline.
189-
* The operation appears in the configured track with proper DevTools visualization.
194+
* Creates performance start/end marks and a final measure.
195+
* All entries have Chrome DevTools Extensibility API payload and are visualized under custom tracks.
190196
* When profiling is disabled, executes and awaits the work function directly without overhead.
191197
*
192198
* @template R - The resolved type of the work promise

0 commit comments

Comments
 (0)