traceperf 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +227 -223
  2. package/dist/browser.d.ts +52 -7
  3. package/dist/browser.js +198 -35
  4. package/dist/browser.js.map +1 -1
  5. package/dist/core/index.d.ts +1 -0
  6. package/dist/core/index.js +1 -0
  7. package/dist/core/index.js.map +1 -1
  8. package/dist/core/optimized-performance-monitor.d.ts +227 -0
  9. package/dist/core/optimized-performance-monitor.js +543 -0
  10. package/dist/core/optimized-performance-monitor.js.map +1 -0
  11. package/dist/esm/browser.d.ts +52 -7
  12. package/dist/esm/browser.js +196 -34
  13. package/dist/esm/browser.js.map +1 -1
  14. package/dist/esm/core/index.d.ts +1 -0
  15. package/dist/esm/core/index.js +1 -0
  16. package/dist/esm/core/index.js.map +1 -1
  17. package/dist/esm/core/optimized-performance-monitor.d.ts +227 -0
  18. package/dist/esm/core/optimized-performance-monitor.js +535 -0
  19. package/dist/esm/core/optimized-performance-monitor.js.map +1 -0
  20. package/dist/esm/index.d.ts +7 -8
  21. package/dist/esm/index.js +18 -19
  22. package/dist/esm/index.js.map +1 -1
  23. package/dist/esm/trackers/execution.d.ts +34 -26
  24. package/dist/esm/trackers/execution.js +99 -60
  25. package/dist/esm/trackers/execution.js.map +1 -1
  26. package/dist/esm/trackers/performance.d.ts +7 -21
  27. package/dist/esm/trackers/performance.js +25 -19
  28. package/dist/esm/trackers/performance.js.map +1 -1
  29. package/dist/esm/types/config.d.ts +16 -2
  30. package/dist/esm/types/index.d.ts +32 -34
  31. package/dist/esm/types/logger.d.ts +11 -2
  32. package/dist/esm/utils/colors.js +12 -0
  33. package/dist/esm/utils/colors.js.map +1 -1
  34. package/dist/esm/utils/string.d.ts +29 -0
  35. package/dist/esm/utils/string.js +45 -0
  36. package/dist/esm/utils/string.js.map +1 -0
  37. package/dist/index.d.ts +7 -8
  38. package/dist/index.js +42 -20
  39. package/dist/index.js.map +1 -1
  40. package/dist/trackers/execution.d.ts +34 -26
  41. package/dist/trackers/execution.js +98 -59
  42. package/dist/trackers/execution.js.map +1 -1
  43. package/dist/trackers/performance.d.ts +7 -21
  44. package/dist/trackers/performance.js +25 -19
  45. package/dist/trackers/performance.js.map +1 -1
  46. package/dist/types/config.d.ts +16 -2
  47. package/dist/types/index.d.ts +32 -34
  48. package/dist/types/logger.d.ts +11 -2
  49. package/dist/types.d.ts +65 -0
  50. package/dist/types.js +6 -0
  51. package/dist/types.js.map +1 -0
  52. package/dist/utils/colors.js +12 -0
  53. package/dist/utils/colors.js.map +1 -1
  54. package/dist/utils/string.d.ts +29 -0
  55. package/dist/utils/string.js +50 -0
  56. package/dist/utils/string.js.map +1 -0
  57. package/package.json +11 -8
package/README.md CHANGED
@@ -1,20 +1,20 @@
1
1
  # TracePerf
2
2
 
3
- Advanced console logging & performance tracking for Node.js applications.
3
+ Advanced performance tracking and execution monitoring for Node.js applications.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/traceperf.svg)](https://www.npmjs.com/package/traceperf)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
7
 
8
8
  ## Features
9
9
 
10
- - **Structured and Visually Appealing Logs**: A better alternative to `console.log()` with colors, icons, and formatting.
11
- - **Execution Flow Tracing**: Track function calls and visualize the execution flow with ASCII art.
12
- - **Nested Function Tracking**: Multiple approaches to track nested function calls with detailed visualization.
13
- - **Performance Bottleneck Detection**: Identify slow functions and get suggestions for optimization.
14
- - **Conditional Logging Modes**: Different logging levels for development, staging, and production.
15
- - **Nested Logging**: Group related logs with indentation for better readability.
16
- - **Auto-Remove Debug Logs**: Automatically filter out debug logs in production.
17
- - **Universal Module Compatibility**: Works with both CommonJS and ESM environments.
10
+ - **High-Performance Execution Monitoring**: Track function execution time with minimal overhead
11
+ - **Memory Usage Tracking**: Monitor memory consumption of your functions and identify memory leaks
12
+ - **Flexible Tracking Modes**: Choose between performance, balanced, and detailed tracking based on your needs
13
+ - **Execution Flow Visualization**: Visualize execution flows with intelligent formatting
14
+ - **Nested Function Tracking**: Track function calls within other functions to understand complex flows
15
+ - **Customizable Threshold Detection**: Focus on functions that exceed specific execution time thresholds
16
+ - **Sampling Control**: Adjust sampling rates to minimize performance impact in production
17
+ - **Universal Module Compatibility**: Works with both CommonJS and ESM environments
18
18
 
19
19
  ## Installation
20
20
 
@@ -22,296 +22,300 @@ Advanced console logging & performance tracking for Node.js applications.
22
22
  npm install traceperf
23
23
  ```
24
24
 
25
- ## Basic Usage
26
-
27
- ### CommonJS (Node.js)
25
+ ## Quick Start
28
26
 
29
27
  ```javascript
30
- const tracePerf = require('traceperf');
31
-
32
- // Basic logging
33
- tracePerf.info('This is an info message');
34
- tracePerf.warn('This is a warning message');
35
- tracePerf.error('This is an error message');
36
- tracePerf.debug('This is a debug message');
37
-
38
- // Logging with objects
39
- tracePerf.info('User data:', { id: 1, name: 'John Doe' });
40
-
41
- // Nested logging with groups
42
- tracePerf.group('User Authentication');
43
- tracePerf.info('Checking credentials');
44
- tracePerf.warn('Invalid password attempt');
45
- tracePerf.groupEnd();
28
+ const traceperf = require('traceperf');
29
+
30
+ // Track a synchronous function
31
+ const result = traceperf.track(() => {
32
+ // Your code here
33
+ return 'result';
34
+ }, { label: 'myFunction' });
35
+
36
+ // Track an asynchronous function
37
+ async function main() {
38
+ const result = await traceperf.track(async () => {
39
+ // Your async code here
40
+ return 'async result';
41
+ }, { label: 'asyncFunction' });
42
+ }
46
43
  ```
47
44
 
48
- ### ESM (ECMAScript Modules)
45
+ ## Tracking Modes
46
+
47
+ TracePerf provides different tracking modes to balance performance with detail:
49
48
 
50
49
  ```javascript
51
- import tracePerf from 'traceperf';
50
+ const { TrackingMode, createTracePerf } = require('traceperf');
51
+
52
+ // Create a custom instance with performance-focused tracking
53
+ const performanceTracker = createTracePerf({
54
+ trackingMode: TrackingMode.PERFORMANCE,
55
+ silent: true,
56
+ threshold: 100, // only track functions that take more than 100ms
57
+ sampleRate: 0.1 // only track 10% of function calls
58
+ });
52
59
 
53
- // Use the same API as with CommonJS
54
- tracePerf.info('This is an info message');
60
+ // Create a custom instance with detailed tracking for development
61
+ const devTracker = createTracePerf({
62
+ trackingMode: TrackingMode.DETAILED,
63
+ trackMemory: true,
64
+ enableNestedTracking: true
65
+ });
55
66
  ```
56
67
 
57
-
58
-
59
- ## Conditional Logging Modes
68
+ ## Tracking Individual Functions
60
69
 
61
70
  ```javascript
62
- // Development mode (default)
63
- tracePerf.setMode('dev');
64
- tracePerf.debug('Debug message'); // Shown
65
- tracePerf.info('Info message'); // Shown
66
- tracePerf.warn('Warning message'); // Shown
67
- tracePerf.error('Error message'); // Shown
68
-
69
- // Staging mode
70
- tracePerf.setMode('staging');
71
- tracePerf.debug('Debug message'); // Not shown
72
- tracePerf.info('Info message'); // Not shown
73
- tracePerf.warn('Warning message'); // Shown
74
- tracePerf.error('Error message'); // Shown
75
-
76
- // Production mode
77
- tracePerf.setMode('prod');
78
- tracePerf.debug('Debug message'); // Not shown
79
- tracePerf.info('Info message'); // Not shown
80
- tracePerf.warn('Warning message'); // Not shown
81
- tracePerf.error('Error message'); // Shown
82
- ```
71
+ // Track a single function execution
72
+ const result = traceperf.track(() => {
73
+ // Function body
74
+ return someValue;
75
+ }, {
76
+ label: 'functionName',
77
+ threshold: 50, // ms
78
+ trackMemory: true
79
+ });
83
80
 
84
- ## Browser Usage (React, Next.js, etc.)
81
+ // Create a trackable version of an existing function
82
+ const myFunction = (a, b) => a + b;
83
+ const trackedFunction = traceperf.createTrackable(myFunction, {
84
+ label: 'addition'
85
+ });
85
86
 
86
- TracePerf also provides a browser-compatible version for use in frontend applications:
87
+ // Now use it normally
88
+ const sum = trackedFunction(5, 3); // will be tracked
89
+ ```
87
90
 
88
- ### ESM (Modern Browsers)
91
+ ## Tracking Methods in a Module
89
92
 
90
93
  ```javascript
91
- // Import the browser version
92
- import tracePerf from 'traceperf/browser';
94
+ const userService = {
95
+ getUser: async (id) => { /* implementation */ },
96
+ updateUser: async (id, data) => { /* implementation */ },
97
+ deleteUser: async (id) => { /* implementation */ }
98
+ };
99
+
100
+ // Register all methods for tracking
101
+ const trackedUserService = traceperf.registerModule(userService);
93
102
 
94
- // Use it just like the Node.js version
95
- tracePerf.info('This works in the browser!');
103
+ // Now all method calls will be tracked
104
+ const user = await trackedUserService.getUser(123);
96
105
  ```
97
106
 
98
- ### CommonJS (Bundlers with CommonJS support)
107
+ ## Advanced Configuration
99
108
 
100
109
  ```javascript
101
- // Import the browser version with require
102
- const tracePerf = require('traceperf/browser');
110
+ const { createTracePerf, TrackingMode } = require('traceperf');
103
111
 
104
- // Use it just like the Node.js version
105
- tracePerf.info('This works in the browser with CommonJS bundlers!');
112
+ const customTracker = createTracePerf({
113
+ // Tracking mode affects detail level and performance impact
114
+ trackingMode: TrackingMode.BALANCED,
115
+
116
+ // Enable or disable performance statistics in console
117
+ silent: false,
118
+
119
+ // Track memory usage (slight performance impact)
120
+ trackMemory: true,
121
+
122
+ // Enable tracking of nested function calls
123
+ enableNestedTracking: true,
124
+
125
+ // Minimum execution time to track (milliseconds)
126
+ threshold: 50,
127
+
128
+ // Percentage of function calls to track (0.0 to 1.0)
129
+ sampleRate: 1.0
130
+ });
106
131
  ```
107
132
 
108
- ### Browser Example
133
+ ## Browser Support
109
134
 
110
- ```javascript
111
- // Import using your preferred method
112
- import tracePerf from 'traceperf/browser';
135
+ TracePerf includes a browser-compatible version:
113
136
 
114
- // Track function performance
115
- function expensiveCalculation() {
116
- // ...complex logic
117
- return result;
118
- }
119
-
120
- const result = tracePerf.track(expensiveCalculation);
121
- ```
137
+ ```javascript
138
+ import traceperf from 'traceperf/browser';
122
139
 
123
- ### React Component Example
124
-
125
- ```jsx
126
- import React, { useEffect } from 'react';
127
- import tracePerf from 'traceperf/browser';
128
-
129
- function DataComponent() {
130
- useEffect(() => {
131
- tracePerf.group('Component Lifecycle');
132
- tracePerf.info('Component mounted');
133
-
134
- // Fetch data with performance tracking
135
- tracePerf.track(async () => {
136
- const data = await fetchData();
137
- // Process data...
138
- }, { label: 'fetchAndProcessData', threshold: 300 });
139
-
140
- return () => {
141
- tracePerf.info('Component unmounting');
142
- tracePerf.groupEnd();
143
- };
144
- }, []);
145
-
146
- // Component rendering...
147
- }
140
+ // Use the same API as in Node.js
141
+ traceperf.track(() => {
142
+ // Your code
143
+ });
148
144
  ```
149
145
 
150
- ## Advanced Usage
146
+ ## Examples
151
147
 
152
- ### Tracking Nested Function Calls
148
+ TracePerf includes several example files to help you get started:
153
149
 
154
- TracePerf provides two approaches for tracking nested function calls, allowing you to visualize the complete execution flow of your application:
150
+ - **`examples/optimized-tracking-example.js`**: Demonstrates various ways to use the optimized tracking implementation
151
+ - **`examples/browser-example.js`**: Shows how to use TracePerf in browser environments
155
152
 
156
- 1. **Using the `createTrackable` method** (recommended)
157
- 2. **Using nested `track` calls**
153
+ ### Tracking an Async Function
158
154
 
159
- #### Using createTrackable (Recommended)
155
+ ```javascript
156
+ const { createTracePerf } = require('traceperf');
157
+ const traceperf = createTracePerf();
158
+
159
+ async function fetchData(url) {
160
+ return traceperf.track(async () => {
161
+ const response = await fetch(url);
162
+ return response.json();
163
+ }, {
164
+ label: 'fetchData',
165
+ trackMemory: true
166
+ });
167
+ }
168
+ ```
160
169
 
161
- The `createTrackable` method creates tracked versions of your functions that can be used in place of the original functions:
170
+ ### Tracking Nested Functions
162
171
 
163
172
  ```javascript
164
- function fetchData() {
165
- processData();
166
- calculateResults();
173
+ const { createTracePerf } = require('traceperf');
174
+ const traceperf = createTracePerf({ enableNestedTracking: true });
175
+
176
+ async function processData() {
177
+ return await traceperf.track(async () => {
178
+ // This function call will be automatically tracked as a child
179
+ const data = await fetchData();
180
+ return transformData(data);
181
+ }, {
182
+ label: 'processData'
183
+ });
167
184
  }
168
185
 
169
- function processData() {
170
- // Some processing logic
186
+ async function fetchData() {
187
+ return await traceperf.track(async () => {
188
+ // Implementation
189
+ }, { label: 'fetchData' });
171
190
  }
172
191
 
173
- function calculateResults() {
174
- // Some calculation logic
192
+ function transformData(data) {
193
+ return traceperf.track(() => {
194
+ // Implementation
195
+ }, { label: 'transformData' });
175
196
  }
197
+ ```
176
198
 
177
- // Create tracked versions of all functions
178
- const trackedFetchData = tracePerf.createTrackable(fetchData, { label: 'fetchData' });
179
- const trackedProcessData = tracePerf.createTrackable(processData, { label: 'processData' });
180
- const trackedCalculateResults = tracePerf.createTrackable(calculateResults, { label: 'calculateResults' });
181
-
182
- // Replace the global references to enable tracking
183
- global.processData = trackedProcessData;
184
- global.calculateResults = trackedCalculateResults;
199
+ ### Optimizing for Production
185
200
 
186
- // Execute the tracked top-level function
187
- trackedFetchData();
188
- ```
201
+ ```javascript
202
+ const { createTracePerf, TrackingMode } = require('traceperf');
203
+
204
+ // Development environment
205
+ const devTracker = createTracePerf({
206
+ trackingMode: TrackingMode.DETAILED,
207
+ silent: false,
208
+ trackMemory: true,
209
+ threshold: 0 // track everything
210
+ });
189
211
 
190
- This will produce a complete execution flow chart showing all nested function calls:
212
+ // Production environment
213
+ const prodTracker = createTracePerf({
214
+ trackingMode: TrackingMode.PERFORMANCE,
215
+ silent: true, // don't log to console
216
+ trackMemory: false, // minimize overhead
217
+ threshold: 100, // only track slow functions
218
+ sampleRate: 0.01 // track only 1% of function calls
219
+ });
191
220
 
192
- ```
193
- Execution Flow:
194
- ┌──────────────────────────────┐
195
- │ fetchData │ ⏱ 200ms
196
- └──────────────────────────────┘
197
- │
198
- ▼
199
- ┌──────────────────────────────┐
200
- │ processData │ ⏱ 500ms ⚠️ SLOW
201
- └──────────────────────────────┘
202
- │
203
- ▼
204
- ┌──────────────────────────────┐
205
- │ calculateResults │ ⏱ 300ms
206
- └──────────────────────────────┘
221
+ // Use based on environment
222
+ const traceperf = process.env.NODE_ENV === 'production' ? prodTracker : devTracker;
207
223
  ```
208
224
 
209
- #### Using Nested Track Calls
225
+ ## Browser Usage
210
226
 
211
- For more complex scenarios, you can use nested `track` calls:
227
+ To use TracePerf in the browser:
212
228
 
213
- ```javascript
214
- tracePerf.track(() => {
215
- // Top-level function logic
229
+ ```html
230
+ <script src="dist/traceperf.browser.js"></script>
231
+ <script>
232
+ const { createTracePerf, TrackingMode } = TracePerf;
216
233
 
217
- tracePerf.track(() => {
218
- // Nested function logic
219
-
220
- tracePerf.track(() => {
221
- // Deeply nested function logic
222
- }, { label: 'deeplyNestedFunction' });
223
-
224
- }, { label: 'nestedFunction' });
234
+ const browserTracker = createTracePerf({
235
+ trackingMode: TrackingMode.BALANCED,
236
+ trackMemory: true
237
+ });
225
238
 
226
- }, { label: 'topLevelFunction' });
239
+ // Now use it to track your functions
240
+ browserTracker.track(() => {
241
+ // DOM operations or other browser-side logic
242
+ }, { label: 'domOperation' });
243
+ </script>
227
244
  ```
228
245
 
229
- #### Controlling Nested Tracking
230
-
231
- You can control nested tracking with the following option:
246
+ Or with ES modules:
232
247
 
233
248
  ```javascript
234
- // Disable nested tracking entirely
235
- tracePerf.track(fetchData, { enableNestedTracking: false });
236
- ```
237
-
238
- For more examples, see the `examples/nested-tracking.js` and `examples/auto-tracking-example.js` files in the repository.
249
+ import { createTracePerf, TrackingMode } from 'traceperf/browser';
239
250
 
240
- ## API Reference for Nested Tracking
241
-
242
- ### createTrackable
251
+ const browserTracker = createTracePerf({
252
+ trackingMode: TrackingMode.BALANCED
253
+ });
243
254
 
244
- ```javascript
245
- tracePerf.createTrackable(fn, options)
255
+ // Track a DOM operation
256
+ browserTracker.track(() => {
257
+ document.getElementById('output').textContent = 'Updated';
258
+ }, { label: 'updateDOM' });
246
259
  ```
247
260
 
248
- Creates a tracked version of a function that can be used for nested function tracking.
261
+ ## Advanced Tracking Features
249
262
 
250
- - `fn`: The function to make trackable
251
- - `options`: Options for tracking
252
- - `label`: Custom label for the function (defaults to function name)
253
- - `threshold`: Performance threshold in milliseconds
254
- - `includeMemory`: Whether to include memory usage tracking
255
- - `enableNestedTracking`: Whether to enable nested tracking (default: true)
256
-
257
- Returns a new function that, when called, will track the execution of the original function.
258
-
259
- ### Track Options for Nested Tracking
260
-
261
- When using the `track` method, you can control nested tracking with these options:
263
+ ### Tracking with Different Modes
262
264
 
263
265
  ```javascript
264
- tracePerf.track(fn, {
265
- // ... other options
266
- enableNestedTracking: true, // Enable/disable nested tracking
266
+ const { createTracePerf, TrackingMode } = require('traceperf');
267
+
268
+ // Performance mode - minimal overhead
269
+ const performanceTracker = createTracePerf({
270
+ trackingMode: TrackingMode.PERFORMANCE
267
271
  });
268
- ```
269
272
 
270
- ```javascript
271
- const { createLogger } = require('traceperf');
272
-
273
- // Create a custom logger instance
274
- const logger = createLogger({
275
- mode: 'dev',
276
- level: 'debug',
277
- colorize: true,
278
- timestamp: true,
279
- performanceThreshold: 100, // ms
280
- indentSize: 2,
273
+ // Balanced mode - moderate detail with reasonable overhead
274
+ const balancedTracker = createTracePerf({
275
+ trackingMode: TrackingMode.BALANCED
281
276
  });
282
277
 
283
- // Use the custom logger
284
- logger.info('Custom logger');
278
+ // Detailed mode - maximum information
279
+ const detailedTracker = createTracePerf({
280
+ trackingMode: TrackingMode.DETAILED
281
+ });
285
282
  ```
286
283
 
287
- ## API Reference
288
-
289
- ### Logging Methods
284
+ ### Using Thresholds to Filter Results
290
285
 
291
- - `info(message, ...args)`: Log an informational message
292
- - `warn(message, ...args)`: Log a warning message
293
- - `error(message, ...args)`: Log an error message
294
- - `debug(message, ...args)`: Log a debug message (filtered in production)
295
-
296
- ### Grouping
286
+ ```javascript
287
+ const { createTracePerf } = require('traceperf');
288
+ const tracker = createTracePerf();
297
289
 
298
- - `group(label)`: Start a new log group with the given label
299
- - `groupEnd()`: End the current log group
290
+ // Only log functions that take more than 50ms
291
+ tracker.track(slowFunction, { threshold: 50 });
300
292
 
301
- ### Execution Tracking
293
+ // Different thresholds for different functions
294
+ tracker.track(criticalFunction, { threshold: 10 }); // Low threshold for critical paths
295
+ tracker.track(backgroundTask, { threshold: 200 }); // Higher threshold for background tasks
296
+ ```
302
297
 
303
- - `track(fn, options)`: Track the execution of a function and log performance metrics
304
- - `options.label`: Custom label for the tracked function
305
- - `options.threshold`: Performance threshold in milliseconds
306
- - `options.includeMemory`: Whether to include memory usage tracking
307
- - `options.silent`: Whether to suppress logging for this tracking
298
+ ### Memory Tracking
308
299
 
309
- ### Configuration
300
+ ```javascript
301
+ const { createTracePerf } = require('traceperf');
302
+ const tracker = createTracePerf({ trackMemory: true });
303
+
304
+ // Track memory usage for memory-intensive operations
305
+ const result = tracker.track(() => {
306
+ // Memory-intensive operations
307
+ const largeArray = new Array(1000000).fill(Math.random());
308
+ return processArray(largeArray);
309
+ }, { label: 'memoryIntensiveOperation' });
310
+ ```
310
311
 
311
- - `setMode(mode)`: Set the operational mode ('dev', 'staging', 'prod')
312
- - `getMode()`: Get the current operational mode
312
+ For more examples, see the example files in the `examples/` directory.
313
313
 
314
314
  ## License
315
315
 
316
316
  MIT
317
317
 
318
+ ## Website
319
+
320
+ Visit our website at [traceperf.com](https://traceperf.com) for more information, interactive examples, and detailed documentation.
321
+
package/dist/browser.d.ts CHANGED
@@ -5,6 +5,12 @@
5
5
  * in React, Next.js, or other frontend applications.
6
6
  */
7
7
  import { ILoggerConfig, LogMode, ITrackOptions } from './types';
8
+ export declare const TrackingMode: {
9
+ PERFORMANCE: string;
10
+ BALANCED: string;
11
+ DETAILED: string;
12
+ DEBUG: string;
13
+ };
8
14
  /**
9
15
  * Browser-compatible performance monitoring
10
16
  */
@@ -17,12 +23,25 @@ declare class BrowserPerformanceMonitor {
17
23
  startTimer(label: string): string;
18
24
  endTimer(id: string): number;
19
25
  isBottleneck(duration: number, threshold?: number): boolean;
26
+ /**
27
+ * Get memory usage from browser performance API
28
+ * @returns Memory usage object with heap metrics or undefined if not available
29
+ */
20
30
  getMemoryUsage(): {
21
31
  heapUsed: number;
22
32
  heapTotal: number;
23
33
  external: number;
24
34
  rss: number;
25
- };
35
+ } | undefined;
36
+ /**
37
+ * Calculate memory difference
38
+ * @param start - Starting memory usage
39
+ * @returns Memory difference in bytes
40
+ */
41
+ getMemoryDiff(start: {
42
+ heapUsed: number;
43
+ }): number;
44
+ now(): number;
26
45
  generateSuggestion(functionName: string, duration: number, memoryUsage?: number): string;
27
46
  }
28
47
  /**
@@ -34,6 +53,8 @@ declare class BrowserExecutionTracker {
34
53
  private _currentExecution;
35
54
  private _defaultThreshold;
36
55
  private _globalScope;
56
+ private _trackedFunctions;
57
+ private _performanceMonitor;
37
58
  /**
38
59
  * Create a new BrowserExecutionTracker instance
39
60
  *
@@ -97,6 +118,12 @@ declare class BrowserExecutionTracker {
97
118
  * @param result - The result list
98
119
  */
99
120
  private addChildrenToResult;
121
+ /**
122
+ * Format memory size for display
123
+ * @param bytes Memory usage in bytes
124
+ * @returns Formatted string
125
+ */
126
+ private formatMemorySize;
100
127
  /**
101
128
  * Clear all execution records
102
129
  */
@@ -110,6 +137,7 @@ declare class BrowserLogger {
110
137
  private _indentLevel;
111
138
  private _executionTracker;
112
139
  private _performanceMonitor;
140
+ private _trackingMode;
113
141
  constructor(config?: Partial<ILoggerConfig>);
114
142
  info(message: string | object, ...args: any[]): void;
115
143
  warn(message: string | object, ...args: any[]): void;
@@ -119,6 +147,17 @@ declare class BrowserLogger {
119
147
  groupEnd(): void;
120
148
  setMode(mode: LogMode): void;
121
149
  getMode(): LogMode;
150
+ /**
151
+ * Set the tracking mode
152
+ * @param mode Tracking mode from TrackingMode enum
153
+ * @returns This instance for chaining
154
+ */
155
+ setTrackingMode(mode: string): BrowserLogger;
156
+ /**
157
+ * Get the current tracking mode
158
+ * @returns Current tracking mode
159
+ */
160
+ getTrackingMode(): string;
122
161
  track<T>(fn: () => T, options?: ITrackOptions): T;
123
162
  /**
124
163
  * Create a trackable version of a function
@@ -136,12 +175,18 @@ declare class BrowserLogger {
136
175
  private log;
137
176
  }
138
177
  /**
139
- * Create a new browser logger instance
140
- *
141
- * @param config - Configuration options
142
- * @returns A new BrowserLogger instance
178
+ * Create a browser-compatible logger instance
179
+ * @param config Configuration options
180
+ * @returns Browser logger instance
143
181
  */
144
182
  export declare function createBrowserLogger(config?: Partial<ILoggerConfig>): BrowserLogger;
145
- declare const defaultBrowserLogger: BrowserLogger;
146
- export default defaultBrowserLogger;
183
+ /**
184
+ * Create a browser-compatible TracePerf instance
185
+ * Alias of createBrowserLogger for API consistency with Node.js version
186
+ * @param config Configuration options
187
+ * @returns Browser logger instance
188
+ */
189
+ export declare function createTracePerf(config?: Partial<ILoggerConfig>): BrowserLogger;
190
+ declare const browserLogger: BrowserLogger;
191
+ export default browserLogger;
147
192
  export { BrowserLogger, BrowserPerformanceMonitor, BrowserExecutionTracker };