You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/utils/docs/profiler.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,15 @@
6
6
7
7
The `Profiler` class provides a clean, type-safe API for performance monitoring that integrates seamlessly with Chrome DevTools. It supports both synchronous and asynchronous operations with smart defaults for custom track visualization, enabling developers to track performance bottlenecks and optimize application speed.
8
8
9
+
### Features
10
+
11
+
-**Type-Safe API**: Fully typed UserTiming API for [Chrome DevTools Extensibility API](https://developer.chrome.com/docs/devtools/performance/extension)
12
+
-**Measure API**: Easy-to-use methods for measuring synchronous and asynchronous code execution times.
This profiler extends all options and API from Profiler with automatic process exit handling for buffered performance data.
269
+
### Features
270
+
271
+
-**Crash-safe Write Ahead Log**: Ensures profiling data is saved even if the application crashes.
272
+
-**Recoverable Profiles**: Ability to resume profiling sessions after interruptions or crash.
273
+
-**Automatic Trace Generation**: Generates trace files compatible with Chrome DevTools for in-depth performance analysis.
274
+
-**Multiprocess Support**: Designed to handle profiling over sharded WAL.
275
+
-**Controllable over env vars**: Easily enable or disable profiling through environment variables.
261
276
277
+
This profiler extends all options and API from Profiler with automatic process exit handling for buffered performance data.
262
278
The NodeJSProfiler automatically subscribes to performance observation and installs exit handlers that flush buffered data on process termination (signals, fatal errors, or normal exit).
263
279
280
+
### Exit Handlers
281
+
282
+
The profiler automatically subscribes to process events (`exit`, `SIGINT`, `SIGTERM`, `SIGQUIT`, `uncaughtException`, `unhandledRejection`) during construction. When any of these occur, the handlers call `close()` to ensure buffered data is flushed.
283
+
284
+
The `close()` method is idempotent and safe to call from exit handlers. It unsubscribes from exit handlers, closes the WAL sink, and unsubscribes from the performance observer, ensuring all buffered performance data is written before process termination.
0 commit comments