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.
- package/README.md +227 -223
- package/dist/browser.d.ts +52 -7
- package/dist/browser.js +198 -35
- package/dist/browser.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/optimized-performance-monitor.d.ts +227 -0
- package/dist/core/optimized-performance-monitor.js +543 -0
- package/dist/core/optimized-performance-monitor.js.map +1 -0
- package/dist/esm/browser.d.ts +52 -7
- package/dist/esm/browser.js +196 -34
- package/dist/esm/browser.js.map +1 -1
- package/dist/esm/core/index.d.ts +1 -0
- package/dist/esm/core/index.js +1 -0
- package/dist/esm/core/index.js.map +1 -1
- package/dist/esm/core/optimized-performance-monitor.d.ts +227 -0
- package/dist/esm/core/optimized-performance-monitor.js +535 -0
- package/dist/esm/core/optimized-performance-monitor.js.map +1 -0
- package/dist/esm/index.d.ts +7 -8
- package/dist/esm/index.js +18 -19
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/trackers/execution.d.ts +34 -26
- package/dist/esm/trackers/execution.js +99 -60
- package/dist/esm/trackers/execution.js.map +1 -1
- package/dist/esm/trackers/performance.d.ts +7 -21
- package/dist/esm/trackers/performance.js +25 -19
- package/dist/esm/trackers/performance.js.map +1 -1
- package/dist/esm/types/config.d.ts +16 -2
- package/dist/esm/types/index.d.ts +32 -34
- package/dist/esm/types/logger.d.ts +11 -2
- package/dist/esm/utils/colors.js +12 -0
- package/dist/esm/utils/colors.js.map +1 -1
- package/dist/esm/utils/string.d.ts +29 -0
- package/dist/esm/utils/string.js +45 -0
- package/dist/esm/utils/string.js.map +1 -0
- package/dist/index.d.ts +7 -8
- package/dist/index.js +42 -20
- package/dist/index.js.map +1 -1
- package/dist/trackers/execution.d.ts +34 -26
- package/dist/trackers/execution.js +98 -59
- package/dist/trackers/execution.js.map +1 -1
- package/dist/trackers/performance.d.ts +7 -21
- package/dist/trackers/performance.js +25 -19
- package/dist/trackers/performance.js.map +1 -1
- package/dist/types/config.d.ts +16 -2
- package/dist/types/index.d.ts +32 -34
- package/dist/types/logger.d.ts +11 -2
- package/dist/types.d.ts +65 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/colors.js +12 -0
- package/dist/utils/colors.js.map +1 -1
- package/dist/utils/string.d.ts +29 -0
- package/dist/utils/string.js +50 -0
- package/dist/utils/string.js.map +1 -0
- package/package.json +11 -8
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Optimized Performance Monitoring Library
|
|
4
|
+
*
|
|
5
|
+
* This implementation incorporates all optimizations from benchmarking:
|
|
6
|
+
* 1. Tiered tracking modes for performance vs. detail balance
|
|
7
|
+
* 2. Context preservation for object methods
|
|
8
|
+
* 3. Async/Promise support
|
|
9
|
+
* 4. Browser/Node.js environment detection
|
|
10
|
+
* 5. Memory usage tracking optimizations
|
|
11
|
+
* 6. Module registration capability
|
|
12
|
+
* 7. Enhanced visualization
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OptimizedPerformanceMonitor = exports.OptimizedExecutionTracker = exports.getDuration = exports.getTimestamp = exports.getMemoryUsage = exports.TrackingModes = void 0;
|
|
16
|
+
// Define tracking mode constants directly to avoid circular dependency
|
|
17
|
+
exports.TrackingModes = {
|
|
18
|
+
PERFORMANCE: 'performance',
|
|
19
|
+
BALANCED: 'balanced',
|
|
20
|
+
DETAILED: 'detailed',
|
|
21
|
+
DEBUG: 'debug'
|
|
22
|
+
};
|
|
23
|
+
// Define default tracking mode separately to avoid circular dependency
|
|
24
|
+
const DEFAULT_TRACKING_MODE = exports.TrackingModes.BALANCED;
|
|
25
|
+
/**
|
|
26
|
+
* Get current memory usage with environment detection
|
|
27
|
+
* @returns Memory usage in bytes
|
|
28
|
+
*/
|
|
29
|
+
const getMemoryUsage = () => {
|
|
30
|
+
var _a;
|
|
31
|
+
// Safe check for Node.js process.memoryUsage()
|
|
32
|
+
if (typeof process !== 'undefined' && process.memoryUsage) {
|
|
33
|
+
const mem = process.memoryUsage();
|
|
34
|
+
return mem.heapUsed;
|
|
35
|
+
}
|
|
36
|
+
// Browser memory API if available
|
|
37
|
+
else if (typeof performance !== 'undefined' && 'memory' in performance) {
|
|
38
|
+
// @ts-expect-error This is a browser-specific check
|
|
39
|
+
return ((_a = window.performance.memory) === null || _a === void 0 ? void 0 : _a.usedJSHeapSize) || 0;
|
|
40
|
+
}
|
|
41
|
+
// Fallback when no memory API available
|
|
42
|
+
return 0;
|
|
43
|
+
};
|
|
44
|
+
exports.getMemoryUsage = getMemoryUsage;
|
|
45
|
+
/**
|
|
46
|
+
* Get high-resolution timestamp with environment detection
|
|
47
|
+
* @returns Timestamp in nanoseconds
|
|
48
|
+
*/
|
|
49
|
+
const getTimestamp = () => {
|
|
50
|
+
// Use performance.now() in browsers (convert to nanoseconds)
|
|
51
|
+
if (typeof performance !== 'undefined' && performance.now) {
|
|
52
|
+
return performance.now() * 1000000;
|
|
53
|
+
}
|
|
54
|
+
// Use process.hrtime() in Node.js
|
|
55
|
+
else if (typeof process !== 'undefined' && process.hrtime) {
|
|
56
|
+
const hrTime = process.hrtime();
|
|
57
|
+
return hrTime[0] * 1000000000 + hrTime[1];
|
|
58
|
+
}
|
|
59
|
+
// Fallback to Date.now() (converted to nanoseconds)
|
|
60
|
+
return Date.now() * 1000000;
|
|
61
|
+
};
|
|
62
|
+
exports.getTimestamp = getTimestamp;
|
|
63
|
+
/**
|
|
64
|
+
* Calculate time difference between two timestamps
|
|
65
|
+
* @param startTime Starting timestamp in nanoseconds
|
|
66
|
+
* @returns Duration in nanoseconds
|
|
67
|
+
*/
|
|
68
|
+
const getDuration = (startTime) => {
|
|
69
|
+
return (0, exports.getTimestamp)() - startTime;
|
|
70
|
+
};
|
|
71
|
+
exports.getDuration = getDuration;
|
|
72
|
+
/**
|
|
73
|
+
* Optimized tracker for individual function executions
|
|
74
|
+
*/
|
|
75
|
+
class OptimizedExecutionTracker {
|
|
76
|
+
/**
|
|
77
|
+
* Create a new execution tracker
|
|
78
|
+
* @param options Tracker configuration options
|
|
79
|
+
*/
|
|
80
|
+
constructor(options = {}) {
|
|
81
|
+
var _a, _b, _c, _d, _e;
|
|
82
|
+
this.executionTree = {};
|
|
83
|
+
this.currentExecutionId = 0;
|
|
84
|
+
this.activeExecutions = new Map();
|
|
85
|
+
// Formatters for flow chart generation
|
|
86
|
+
this._formatters = {
|
|
87
|
+
indent: ' ',
|
|
88
|
+
childPrefix: '├─ ',
|
|
89
|
+
lastChildPrefix: '└─ ',
|
|
90
|
+
linePrefix: '│ ',
|
|
91
|
+
emptyPrefix: ' ',
|
|
92
|
+
errorMarker: '✖ ',
|
|
93
|
+
memoryLabel: '📊 '
|
|
94
|
+
};
|
|
95
|
+
this.showMemoryUsage = (_a = options.showMemoryUsage) !== null && _a !== void 0 ? _a : true;
|
|
96
|
+
this.enableNestedTracking = (_b = options.enableNestedTracking) !== null && _b !== void 0 ? _b : true;
|
|
97
|
+
this.silent = (_c = options.silent) !== null && _c !== void 0 ? _c : false;
|
|
98
|
+
this.trackingMode = (_d = options.trackingMode) !== null && _d !== void 0 ? _d : exports.TrackingModes.BALANCED;
|
|
99
|
+
this.defaultThreshold = (_e = options.threshold) !== null && _e !== void 0 ? _e : 100;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Start timing a function execution
|
|
103
|
+
* @param label Function name or label
|
|
104
|
+
* @param parentExecutionId ID of parent execution if nested
|
|
105
|
+
* @param options Additional options
|
|
106
|
+
* @returns Execution ID
|
|
107
|
+
*/
|
|
108
|
+
startTimer(label, parentExecutionId = null, options = {}) {
|
|
109
|
+
// Skip detailed tracking in performance mode
|
|
110
|
+
const collectMemory = this.trackingMode !== exports.TrackingModes.PERFORMANCE && this.showMemoryUsage;
|
|
111
|
+
const startTime = (0, exports.getTimestamp)();
|
|
112
|
+
const executionId = (++this.currentExecutionId).toString();
|
|
113
|
+
const execution = {
|
|
114
|
+
id: executionId,
|
|
115
|
+
label: label || 'anonymous',
|
|
116
|
+
startTime,
|
|
117
|
+
endTime: 0,
|
|
118
|
+
duration: 0,
|
|
119
|
+
parentId: parentExecutionId,
|
|
120
|
+
children: [],
|
|
121
|
+
args: options.captureArgs && options.args ?
|
|
122
|
+
Array.from(options.args).map(arg => String(arg).substring(0, 50)) : [],
|
|
123
|
+
complete: false
|
|
124
|
+
};
|
|
125
|
+
// Collect memory usage if enabled
|
|
126
|
+
if (collectMemory) {
|
|
127
|
+
execution.memoryAtStart = (0, exports.getMemoryUsage)();
|
|
128
|
+
execution.memoryAtEnd = 0;
|
|
129
|
+
execution.memoryDelta = 0;
|
|
130
|
+
}
|
|
131
|
+
// Add to parent's children if parent exists
|
|
132
|
+
if (parentExecutionId && this.activeExecutions.has(parentExecutionId)) {
|
|
133
|
+
const parent = this.activeExecutions.get(parentExecutionId);
|
|
134
|
+
if (parent && parent.children) {
|
|
135
|
+
parent.children.push(executionId);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Store in active executions map
|
|
139
|
+
this.activeExecutions.set(executionId, execution);
|
|
140
|
+
return executionId;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* End timing a function execution
|
|
144
|
+
* @param executionId ID of the execution to end
|
|
145
|
+
* @param result Result of the function
|
|
146
|
+
* @param error Error if the function threw
|
|
147
|
+
* @returns Execution data
|
|
148
|
+
*/
|
|
149
|
+
endTimer(executionId, result, error = null) {
|
|
150
|
+
if (!this.activeExecutions.has(executionId)) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
const execution = this.activeExecutions.get(executionId);
|
|
154
|
+
execution.endTime = (0, exports.getTimestamp)();
|
|
155
|
+
execution.duration = execution.endTime - execution.startTime;
|
|
156
|
+
execution.result = result;
|
|
157
|
+
execution.error = error;
|
|
158
|
+
execution.complete = true;
|
|
159
|
+
// Only collect memory in non-performance modes
|
|
160
|
+
if (this.trackingMode !== exports.TrackingModes.PERFORMANCE && this.showMemoryUsage) {
|
|
161
|
+
execution.memoryAtEnd = (0, exports.getMemoryUsage)();
|
|
162
|
+
execution.memoryDelta = execution.memoryAtEnd - (execution.memoryAtStart || 0);
|
|
163
|
+
}
|
|
164
|
+
// Store in the execution tree
|
|
165
|
+
this.executionTree[executionId] = { ...execution };
|
|
166
|
+
// Generate flow chart if not silent
|
|
167
|
+
if (!this.silent && this.trackingMode !== exports.TrackingModes.PERFORMANCE) {
|
|
168
|
+
const flowChart = this._generateExecutionFlowChart(execution);
|
|
169
|
+
console.log(flowChart);
|
|
170
|
+
}
|
|
171
|
+
return execution;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Generate a visualization of the execution flow
|
|
175
|
+
* @param execution The execution to visualize
|
|
176
|
+
* @param depth Current depth in the tree
|
|
177
|
+
* @param isLastChild Whether this is the last child
|
|
178
|
+
* @param ancestors Array tracking if parents were last children
|
|
179
|
+
* @returns Formatted execution flow chart
|
|
180
|
+
*/
|
|
181
|
+
_generateExecutionFlowChart(execution, depth = 0, isLastChild = true, ancestors = []) {
|
|
182
|
+
// Skip in performance mode
|
|
183
|
+
if (this.trackingMode === exports.TrackingModes.PERFORMANCE) {
|
|
184
|
+
return '';
|
|
185
|
+
}
|
|
186
|
+
// Build the flow chart
|
|
187
|
+
let flowChart = '';
|
|
188
|
+
// Format the execution line based on tracking mode
|
|
189
|
+
const durationStr = (execution.duration / 1000000).toFixed(3);
|
|
190
|
+
const formatters = this._formatters;
|
|
191
|
+
let line = `${formatters.indent.repeat(depth)}${isLastChild ? formatters.lastChildPrefix : formatters.childPrefix}${execution.label}: ${durationStr} ms`;
|
|
192
|
+
// Add memory usage if enabled and in detailed modes
|
|
193
|
+
if (this.showMemoryUsage &&
|
|
194
|
+
execution.memoryDelta !== undefined &&
|
|
195
|
+
this.trackingMode !== exports.TrackingModes.PERFORMANCE) {
|
|
196
|
+
const memoryStr = (execution.memoryDelta / 1024).toFixed(2);
|
|
197
|
+
const sign = execution.memoryDelta >= 0 ? '+' : '';
|
|
198
|
+
line += ` ${formatters.memoryLabel}${sign}${memoryStr} KB`;
|
|
199
|
+
}
|
|
200
|
+
// Add error indicator
|
|
201
|
+
if (execution.error && (this.trackingMode === exports.TrackingModes.DETAILED || this.trackingMode === exports.TrackingModes.DEBUG)) {
|
|
202
|
+
line += ` ${formatters.errorMarker}${execution.error.message}`;
|
|
203
|
+
}
|
|
204
|
+
flowChart += line + '\n';
|
|
205
|
+
// Process children (skip in performance mode)
|
|
206
|
+
if (execution.children && execution.children.length > 0 && this.trackingMode !== exports.TrackingModes.PERFORMANCE) {
|
|
207
|
+
const childExecutions = execution.children
|
|
208
|
+
.map(childId => this.executionTree[childId] || this.activeExecutions.get(childId))
|
|
209
|
+
.filter(Boolean);
|
|
210
|
+
for (let i = 0; i < childExecutions.length; i++) {
|
|
211
|
+
const isLast = i === childExecutions.length - 1;
|
|
212
|
+
const childFlowChart = this._generateExecutionFlowChart(childExecutions[i], depth + 1, isLast, [...ancestors, !isLastChild]);
|
|
213
|
+
flowChart += childFlowChart;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return flowChart;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Create a trackable version of a function
|
|
220
|
+
* @param fn Function to track
|
|
221
|
+
* @param options Tracking options
|
|
222
|
+
* @returns Tracked version of the function
|
|
223
|
+
*/
|
|
224
|
+
createTrackable(fn, options = {}) {
|
|
225
|
+
if (typeof fn !== 'function') {
|
|
226
|
+
throw new Error('First argument must be a function');
|
|
227
|
+
}
|
|
228
|
+
const label = options.label || fn.name || 'anonymous';
|
|
229
|
+
const parentExecutionId = options.parentExecutionId || null;
|
|
230
|
+
const silent = options.hasOwnProperty('silent') ? options.silent : this.silent;
|
|
231
|
+
const trackingMode = options.trackingMode || this.trackingMode;
|
|
232
|
+
const sampleRate = options.hasOwnProperty('sampleRate') ?
|
|
233
|
+
Math.max(0, Math.min(1, options.sampleRate)) : 1.0;
|
|
234
|
+
// Performance optimization - if in performance mode and silent, return original function
|
|
235
|
+
if (trackingMode === exports.TrackingModes.PERFORMANCE &&
|
|
236
|
+
(options.silent || this.silent) &&
|
|
237
|
+
!this.enableNestedTracking) {
|
|
238
|
+
return fn;
|
|
239
|
+
}
|
|
240
|
+
// Create the tracked function using arrow function to preserve 'this'
|
|
241
|
+
const trackedFn = (...args) => {
|
|
242
|
+
// Apply sampling - randomly decide whether to track this call
|
|
243
|
+
const shouldSample = Math.random() < sampleRate;
|
|
244
|
+
// If not sampling this call, just execute the function directly
|
|
245
|
+
if (!shouldSample) {
|
|
246
|
+
return fn.apply(this, args);
|
|
247
|
+
}
|
|
248
|
+
// Start tracking the execution
|
|
249
|
+
const executionId = this.startTimer(label, parentExecutionId, {
|
|
250
|
+
trackMemory: options.trackMemory !== undefined ? options.trackMemory : this.showMemoryUsage,
|
|
251
|
+
captureArgs: options.captureArgs,
|
|
252
|
+
args: args
|
|
253
|
+
});
|
|
254
|
+
try {
|
|
255
|
+
// Execute the function with correct this context
|
|
256
|
+
const result = fn.apply(this, args);
|
|
257
|
+
// Handle promises
|
|
258
|
+
if (result && typeof result.then === 'function') {
|
|
259
|
+
return result
|
|
260
|
+
.then((resolvedValue) => {
|
|
261
|
+
this.endTimer(executionId, resolvedValue);
|
|
262
|
+
return resolvedValue;
|
|
263
|
+
})
|
|
264
|
+
.catch((error) => {
|
|
265
|
+
this.endTimer(executionId, undefined, error);
|
|
266
|
+
throw error; // Re-throw to preserve error behavior
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
// Handle synchronous functions
|
|
270
|
+
this.endTimer(executionId, result);
|
|
271
|
+
return result;
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
// Handle synchronous errors
|
|
275
|
+
this.endTimer(executionId, undefined, error);
|
|
276
|
+
throw error; // Re-throw to preserve error behavior
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
// Preserve function properties
|
|
280
|
+
Object.defineProperty(trackedFn, 'name', { value: fn.name, configurable: true });
|
|
281
|
+
Object.defineProperty(trackedFn, 'length', { value: fn.length });
|
|
282
|
+
return trackedFn;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Track a module's methods
|
|
286
|
+
* @param module Module to track
|
|
287
|
+
* @param options Tracking options
|
|
288
|
+
* @returns Tracked module
|
|
289
|
+
*/
|
|
290
|
+
trackModule(module, options = {}) {
|
|
291
|
+
if (!module || typeof module !== 'object') {
|
|
292
|
+
throw new Error('Module must be an object');
|
|
293
|
+
}
|
|
294
|
+
const prefix = options.prefix || '';
|
|
295
|
+
const trackingMode = options.trackingMode || this.trackingMode;
|
|
296
|
+
// Performance optimization - if in performance mode and silent, return original module
|
|
297
|
+
if (trackingMode === exports.TrackingModes.PERFORMANCE &&
|
|
298
|
+
(options.silent || this.silent) &&
|
|
299
|
+
!this.enableNestedTracking) {
|
|
300
|
+
return module;
|
|
301
|
+
}
|
|
302
|
+
// Create a new object to avoid modifying the original
|
|
303
|
+
const trackedModule = Object.create(Object.getPrototypeOf(module));
|
|
304
|
+
// Copy own properties
|
|
305
|
+
Object.getOwnPropertyNames(module).forEach(key => {
|
|
306
|
+
const descriptor = Object.getOwnPropertyDescriptor(module, key);
|
|
307
|
+
if (!descriptor)
|
|
308
|
+
return;
|
|
309
|
+
// If it's a method, track it
|
|
310
|
+
if (typeof module[key] === 'function') {
|
|
311
|
+
const methodOptions = {
|
|
312
|
+
...options,
|
|
313
|
+
label: `${prefix}${key}`
|
|
314
|
+
};
|
|
315
|
+
trackedModule[key] = this.createTrackable(module[key], methodOptions);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
// Otherwise, just copy the property
|
|
319
|
+
Object.defineProperty(trackedModule, key, descriptor);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
return trackedModule;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Track a function execution directly
|
|
326
|
+
* @param fn Function to track
|
|
327
|
+
* @param options Tracking options
|
|
328
|
+
* @returns Function result
|
|
329
|
+
*/
|
|
330
|
+
track(fn, options = {}) {
|
|
331
|
+
// Create a trackable version and call it immediately
|
|
332
|
+
const trackableFn = this.createTrackable(fn, options);
|
|
333
|
+
return trackableFn.apply(options.thisContext || this, options.args || []);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Reset the tracker state
|
|
337
|
+
*/
|
|
338
|
+
reset() {
|
|
339
|
+
this.executionTree = {};
|
|
340
|
+
this.currentExecutionId = 0;
|
|
341
|
+
this.activeExecutions = new Map();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
exports.OptimizedExecutionTracker = OptimizedExecutionTracker;
|
|
345
|
+
/**
|
|
346
|
+
* Main performance monitoring interface
|
|
347
|
+
*/
|
|
348
|
+
class OptimizedPerformanceMonitor {
|
|
349
|
+
/**
|
|
350
|
+
* Create a new performance monitor instance
|
|
351
|
+
* @param options Configuration options
|
|
352
|
+
*/
|
|
353
|
+
constructor(options = {}) {
|
|
354
|
+
this.config = {
|
|
355
|
+
trackingMode: options.trackingMode || DEFAULT_TRACKING_MODE,
|
|
356
|
+
silent: options.silent || false,
|
|
357
|
+
trackMemory: options.trackMemory !== undefined ? options.trackMemory : true,
|
|
358
|
+
enableNestedTracking: options.enableNestedTracking !== undefined ? options.enableNestedTracking : true,
|
|
359
|
+
threshold: options.threshold || 100,
|
|
360
|
+
sampleRate: options.sampleRate !== undefined ?
|
|
361
|
+
Math.max(0, Math.min(1, options.sampleRate)) : 1.0 // Clamp between 0 and 1
|
|
362
|
+
};
|
|
363
|
+
this.executionTracker = new OptimizedExecutionTracker({
|
|
364
|
+
trackingMode: this.config.trackingMode,
|
|
365
|
+
silent: this.config.silent,
|
|
366
|
+
showMemoryUsage: this.config.trackMemory,
|
|
367
|
+
enableNestedTracking: this.config.enableNestedTracking,
|
|
368
|
+
threshold: this.config.threshold
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Track a function execution
|
|
373
|
+
* @param fn The function to track
|
|
374
|
+
* @param options Tracking options
|
|
375
|
+
* @returns Result of the tracked function
|
|
376
|
+
*/
|
|
377
|
+
track(fn, options = {}) {
|
|
378
|
+
if (typeof fn !== 'function') {
|
|
379
|
+
throw new Error('First argument must be a function');
|
|
380
|
+
}
|
|
381
|
+
// Merge global config with function-specific options
|
|
382
|
+
const trackingOptions = {
|
|
383
|
+
label: options.label || fn.name || 'anonymous',
|
|
384
|
+
trackingMode: options.trackingMode || this.config.trackingMode,
|
|
385
|
+
silent: options.hasOwnProperty('silent') ? options.silent : this.config.silent,
|
|
386
|
+
trackMemory: options.hasOwnProperty('trackMemory') ? options.trackMemory : this.config.trackMemory,
|
|
387
|
+
sampleRate: options.hasOwnProperty('sampleRate') ? options.sampleRate : this.config.sampleRate,
|
|
388
|
+
captureArgs: options.hasOwnProperty('captureArgs') ? options.captureArgs : false,
|
|
389
|
+
parentExecutionId: options.parentExecutionId || null,
|
|
390
|
+
thisContext: options.thisContext,
|
|
391
|
+
args: options.args
|
|
392
|
+
};
|
|
393
|
+
// Use the tracker to directly track the function
|
|
394
|
+
return this.executionTracker.track(fn, trackingOptions);
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Create a trackable version of a function
|
|
398
|
+
* @param fn The function to track
|
|
399
|
+
* @param options Tracking options
|
|
400
|
+
* @returns Tracked version of the function
|
|
401
|
+
*/
|
|
402
|
+
createTrackable(fn, options = {}) {
|
|
403
|
+
if (typeof fn !== 'function') {
|
|
404
|
+
throw new Error('First argument must be a function');
|
|
405
|
+
}
|
|
406
|
+
// Merge global config with function-specific options
|
|
407
|
+
const trackingOptions = {
|
|
408
|
+
label: options.label || fn.name || 'anonymous',
|
|
409
|
+
trackingMode: options.trackingMode || this.config.trackingMode,
|
|
410
|
+
silent: options.hasOwnProperty('silent') ? options.silent : this.config.silent,
|
|
411
|
+
trackMemory: options.hasOwnProperty('trackMemory') ? options.trackMemory : this.config.trackMemory,
|
|
412
|
+
sampleRate: options.hasOwnProperty('sampleRate') ? options.sampleRate : this.config.sampleRate,
|
|
413
|
+
captureArgs: options.hasOwnProperty('captureArgs') ? options.captureArgs : false,
|
|
414
|
+
parentExecutionId: options.parentExecutionId || null
|
|
415
|
+
};
|
|
416
|
+
return this.executionTracker.createTrackable(fn, trackingOptions);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Register a module for tracking
|
|
420
|
+
* @param module The module or object containing methods to track
|
|
421
|
+
* @param options Tracking options
|
|
422
|
+
* @returns Modified module with tracked methods
|
|
423
|
+
*/
|
|
424
|
+
registerModule(module, options = {}) {
|
|
425
|
+
if (!module || typeof module !== 'object') {
|
|
426
|
+
throw new Error('Module must be an object');
|
|
427
|
+
}
|
|
428
|
+
// Merge global config with module-specific options
|
|
429
|
+
const trackingOptions = {
|
|
430
|
+
prefix: options.prefix || '',
|
|
431
|
+
trackingMode: options.trackingMode || this.config.trackingMode,
|
|
432
|
+
silent: options.hasOwnProperty('silent') ? options.silent : this.config.silent,
|
|
433
|
+
trackMemory: options.hasOwnProperty('trackMemory') ? options.trackMemory : this.config.trackMemory,
|
|
434
|
+
sampleRate: options.hasOwnProperty('sampleRate') ? options.sampleRate : this.config.sampleRate,
|
|
435
|
+
captureArgs: options.hasOwnProperty('captureArgs') ? options.captureArgs : false
|
|
436
|
+
};
|
|
437
|
+
return this.executionTracker.trackModule(module, trackingOptions);
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Set configuration options
|
|
441
|
+
* @param config Configuration to update
|
|
442
|
+
* @returns Current configuration after update
|
|
443
|
+
*/
|
|
444
|
+
setConfig(config = {}) {
|
|
445
|
+
// Update trackingMode if specified
|
|
446
|
+
if (config.trackingMode) {
|
|
447
|
+
this.config.trackingMode = config.trackingMode;
|
|
448
|
+
this.executionTracker.trackingMode = config.trackingMode;
|
|
449
|
+
}
|
|
450
|
+
// Update silent if specified
|
|
451
|
+
if (config.silent !== undefined) {
|
|
452
|
+
this.config.silent = config.silent;
|
|
453
|
+
this.executionTracker.silent = config.silent;
|
|
454
|
+
}
|
|
455
|
+
// Update trackMemory if specified
|
|
456
|
+
if (config.trackMemory !== undefined) {
|
|
457
|
+
this.config.trackMemory = config.trackMemory;
|
|
458
|
+
this.executionTracker.showMemoryUsage = config.trackMemory;
|
|
459
|
+
}
|
|
460
|
+
// Update enableNestedTracking if specified
|
|
461
|
+
if (config.enableNestedTracking !== undefined) {
|
|
462
|
+
this.config.enableNestedTracking = config.enableNestedTracking;
|
|
463
|
+
this.executionTracker.enableNestedTracking = config.enableNestedTracking;
|
|
464
|
+
}
|
|
465
|
+
// Update threshold if specified
|
|
466
|
+
if (config.threshold !== undefined) {
|
|
467
|
+
this.config.threshold = config.threshold;
|
|
468
|
+
this.executionTracker.defaultThreshold = config.threshold;
|
|
469
|
+
}
|
|
470
|
+
// Update sampleRate if specified
|
|
471
|
+
if (config.sampleRate !== undefined) {
|
|
472
|
+
this.config.sampleRate = Math.max(0, Math.min(1, config.sampleRate));
|
|
473
|
+
}
|
|
474
|
+
return { ...this.config };
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Enable silent mode (no console output)
|
|
478
|
+
* @returns This instance for chaining
|
|
479
|
+
*/
|
|
480
|
+
enableSilentMode() {
|
|
481
|
+
this.config.silent = true;
|
|
482
|
+
this.executionTracker.silent = true;
|
|
483
|
+
return this;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Disable silent mode (allow console output)
|
|
487
|
+
* @returns This instance for chaining
|
|
488
|
+
*/
|
|
489
|
+
disableSilentMode() {
|
|
490
|
+
this.config.silent = false;
|
|
491
|
+
this.executionTracker.silent = false;
|
|
492
|
+
return this;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Set the tracking mode
|
|
496
|
+
* @param mode Tracking mode from TrackingMode enum
|
|
497
|
+
* @returns This instance for chaining
|
|
498
|
+
*/
|
|
499
|
+
setTrackingMode(mode) {
|
|
500
|
+
this.config.trackingMode = mode;
|
|
501
|
+
this.executionTracker.trackingMode = mode;
|
|
502
|
+
return this;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Enable memory usage tracking
|
|
506
|
+
* @returns This instance for chaining
|
|
507
|
+
*/
|
|
508
|
+
enableMemoryTracking() {
|
|
509
|
+
this.config.trackMemory = true;
|
|
510
|
+
this.executionTracker.showMemoryUsage = true;
|
|
511
|
+
return this;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Disable memory usage tracking
|
|
515
|
+
* @returns This instance for chaining
|
|
516
|
+
*/
|
|
517
|
+
disableMemoryTracking() {
|
|
518
|
+
this.config.trackMemory = false;
|
|
519
|
+
this.executionTracker.showMemoryUsage = false;
|
|
520
|
+
return this;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Set the sampling rate
|
|
524
|
+
* @param rate Sampling rate between 0.0 and 1.0
|
|
525
|
+
* @returns This instance for chaining
|
|
526
|
+
*/
|
|
527
|
+
setSampleRate(rate) {
|
|
528
|
+
this.config.sampleRate = Math.max(0, Math.min(1, rate));
|
|
529
|
+
return this;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Reset the tracker state
|
|
533
|
+
* @returns This instance for chaining
|
|
534
|
+
*/
|
|
535
|
+
reset() {
|
|
536
|
+
this.executionTracker.reset();
|
|
537
|
+
return this;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
exports.OptimizedPerformanceMonitor = OptimizedPerformanceMonitor;
|
|
541
|
+
// Remove singleton instance to avoid circular dependency - it will be created in index.ts
|
|
542
|
+
// export const optimizedTracePerf = new OptimizedPerformanceMonitor();
|
|
543
|
+
//# sourceMappingURL=optimized-performance-monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optimized-performance-monitor.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I,KAAK;QACV,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AArOD,kEAqOC;AAED,0FAA0F;AAC1F,wEAAwE"}
|
package/dist/esm/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
|
|
140
|
-
*
|
|
141
|
-
* @
|
|
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
|
-
|
|
146
|
-
|
|
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 };
|