traceperf 0.2.0 → 1.3.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 +612 -209
- package/dist/__tests__/helpers/console.d.ts +9 -0
- package/dist/__tests__/helpers/console.js +25 -0
- package/dist/__tests__/helpers/console.js.map +1 -0
- package/dist/auto.d.ts +30 -0
- package/dist/auto.js +91 -0
- package/dist/auto.js.map +1 -0
- package/dist/browser.d.ts +52 -144
- package/dist/browser.js +112 -439
- package/dist/browser.js.map +1 -1
- package/dist/cli.d.ts +68 -0
- package/dist/cli.js +528 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/allocations.d.ts +38 -0
- package/dist/core/allocations.js +85 -0
- package/dist/core/allocations.js.map +1 -0
- package/dist/core/cpu-profile.d.ts +84 -0
- package/dist/core/cpu-profile.js +181 -0
- package/dist/core/cpu-profile.js.map +1 -0
- package/dist/core/env.d.ts +10 -0
- package/dist/core/env.js +40 -0
- package/dist/core/env.js.map +1 -0
- package/dist/core/event-loop.d.ts +30 -0
- package/dist/core/event-loop.js +43 -0
- package/dist/core/event-loop.js.map +1 -0
- package/dist/core/explain.d.ts +48 -0
- package/dist/core/explain.js +236 -0
- package/dist/core/explain.js.map +1 -0
- package/dist/core/exporters.d.ts +111 -0
- package/dist/core/exporters.js +236 -0
- package/dist/core/exporters.js.map +1 -0
- package/dist/core/index.d.ts +9 -3
- package/dist/core/index.js +9 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/optimized-performance-monitor.d.ts +180 -26
- package/dist/core/optimized-performance-monitor.js +687 -175
- package/dist/core/optimized-performance-monitor.js.map +1 -1
- package/dist/core/prometheus.d.ts +36 -0
- package/dist/core/prometheus.js +93 -0
- package/dist/core/prometheus.js.map +1 -0
- package/dist/core/records.d.ts +97 -0
- package/dist/core/records.js +87 -0
- package/dist/core/records.js.map +1 -0
- package/dist/core/stats.d.ts +45 -0
- package/dist/core/stats.js +136 -0
- package/dist/core/stats.js.map +1 -0
- package/dist/core/timeline.d.ts +28 -0
- package/dist/core/timeline.js +65 -0
- package/dist/core/timeline.js.map +1 -0
- package/dist/drivers.d.ts +51 -0
- package/dist/drivers.js +205 -0
- package/dist/drivers.js.map +1 -0
- package/dist/esm/auto.d.ts +30 -0
- package/dist/esm/auto.js +87 -0
- package/dist/esm/auto.js.map +1 -0
- package/dist/esm/browser.d.ts +52 -144
- package/dist/esm/browser.js +101 -445
- package/dist/esm/browser.js.map +1 -1
- package/dist/esm/cli.d.ts +68 -0
- package/dist/esm/cli.js +520 -0
- package/dist/esm/cli.js.map +1 -0
- package/dist/esm/core/allocations.d.ts +38 -0
- package/dist/esm/core/allocations.js +82 -0
- package/dist/esm/core/allocations.js.map +1 -0
- package/dist/esm/core/cpu-profile.d.ts +84 -0
- package/dist/esm/core/cpu-profile.js +176 -0
- package/dist/esm/core/cpu-profile.js.map +1 -0
- package/dist/esm/core/env.d.ts +10 -0
- package/dist/esm/core/env.js +35 -0
- package/dist/esm/core/env.js.map +1 -0
- package/dist/esm/core/event-loop.d.ts +30 -0
- package/dist/esm/core/event-loop.js +40 -0
- package/dist/esm/core/event-loop.js.map +1 -0
- package/dist/esm/core/explain.d.ts +48 -0
- package/dist/esm/core/explain.js +232 -0
- package/dist/esm/core/explain.js.map +1 -0
- package/dist/esm/core/exporters.d.ts +111 -0
- package/dist/esm/core/exporters.js +229 -0
- package/dist/esm/core/exporters.js.map +1 -0
- package/dist/esm/core/index.d.ts +10 -4
- package/dist/esm/core/index.js +10 -4
- package/dist/esm/core/index.js.map +1 -1
- package/dist/esm/core/optimized-performance-monitor.d.ts +180 -26
- package/dist/esm/core/optimized-performance-monitor.js +685 -173
- package/dist/esm/core/optimized-performance-monitor.js.map +1 -1
- package/dist/esm/core/prometheus.d.ts +36 -0
- package/dist/esm/core/prometheus.js +89 -0
- package/dist/esm/core/prometheus.js.map +1 -0
- package/dist/esm/core/records.d.ts +97 -0
- package/dist/esm/core/records.js +82 -0
- package/dist/esm/core/records.js.map +1 -0
- package/dist/esm/core/stats.d.ts +45 -0
- package/dist/esm/core/stats.js +131 -0
- package/dist/esm/core/stats.js.map +1 -0
- package/dist/esm/core/timeline.d.ts +28 -0
- package/dist/esm/core/timeline.js +62 -0
- package/dist/esm/core/timeline.js.map +1 -0
- package/dist/esm/drivers.d.ts +51 -0
- package/dist/esm/drivers.js +197 -0
- package/dist/esm/drivers.js.map +1 -0
- package/dist/esm/index.d.ts +13 -5
- package/dist/esm/index.js +21 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/instrument.d.ts +88 -0
- package/dist/esm/instrument.js +274 -0
- package/dist/esm/instrument.js.map +1 -0
- package/dist/esm/integrations.d.ts +70 -0
- package/dist/esm/integrations.js +197 -0
- package/dist/esm/integrations.js.map +1 -0
- package/dist/esm/node-builtins.d.ts +1 -0
- package/dist/esm/node-builtins.js +32 -0
- package/dist/esm/node-builtins.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/register.d.ts +20 -0
- package/dist/esm/register.js +98 -0
- package/dist/esm/register.js.map +1 -0
- package/dist/esm/report-html.d.ts +11 -0
- package/dist/esm/report-html.js +106 -0
- package/dist/esm/report-html.js.map +1 -0
- package/dist/esm/types/index.d.ts +4 -80
- package/dist/esm/types/index.js +1 -2
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/options.d.ts +72 -0
- package/dist/esm/types/options.js +2 -0
- package/dist/esm/types/options.js.map +1 -0
- package/dist/esm/watch.d.ts +17 -0
- package/dist/esm/watch.js +87 -0
- package/dist/esm/watch.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +26 -29
- package/dist/index.js.map +1 -1
- package/dist/instrument.d.ts +88 -0
- package/dist/instrument.js +282 -0
- package/dist/instrument.js.map +1 -0
- package/dist/integrations.d.ts +70 -0
- package/dist/integrations.js +205 -0
- package/dist/integrations.js.map +1 -0
- package/dist/node-builtins.d.ts +1 -0
- package/dist/node-builtins.js +67 -0
- package/dist/node-builtins.js.map +1 -0
- package/dist/register.d.ts +20 -0
- package/dist/register.js +103 -0
- package/dist/register.js.map +1 -0
- package/dist/report-html.d.ts +11 -0
- package/dist/report-html.js +109 -0
- package/dist/report-html.js.map +1 -0
- package/dist/traceperf.browser.js +1910 -0
- package/dist/traceperf.browser.min.js +6 -0
- package/dist/types/index.d.ts +4 -80
- package/dist/types/index.js +1 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/options.d.ts +72 -0
- package/dist/types/{config.js → options.js} +1 -1
- package/dist/types/options.js.map +1 -0
- package/dist/watch.d.ts +17 -0
- package/dist/watch.js +90 -0
- package/dist/watch.js.map +1 -0
- package/package.json +99 -19
- package/dist/core/config.d.ts +0 -77
- package/dist/core/config.js +0 -116
- package/dist/core/config.js.map +0 -1
- package/dist/core/constants.d.ts +0 -78
- package/dist/core/constants.js +0 -109
- package/dist/core/constants.js.map +0 -1
- package/dist/core/logger.d.ts +0 -97
- package/dist/core/logger.js +0 -186
- package/dist/core/logger.js.map +0 -1
- package/dist/esm/core/config.d.ts +0 -77
- package/dist/esm/core/config.js +0 -112
- package/dist/esm/core/config.js.map +0 -1
- package/dist/esm/core/constants.d.ts +0 -78
- package/dist/esm/core/constants.js +0 -106
- package/dist/esm/core/constants.js.map +0 -1
- package/dist/esm/core/logger.d.ts +0 -97
- package/dist/esm/core/logger.js +0 -182
- package/dist/esm/core/logger.js.map +0 -1
- package/dist/esm/formatters/ascii.d.ts +0 -52
- package/dist/esm/formatters/ascii.js +0 -100
- package/dist/esm/formatters/ascii.js.map +0 -1
- package/dist/esm/formatters/cli.d.ts +0 -50
- package/dist/esm/formatters/cli.js +0 -96
- package/dist/esm/formatters/cli.js.map +0 -1
- package/dist/esm/formatters/index.d.ts +0 -3
- package/dist/esm/formatters/index.js +0 -4
- package/dist/esm/formatters/index.js.map +0 -1
- package/dist/esm/formatters/json.d.ts +0 -45
- package/dist/esm/formatters/json.js +0 -85
- package/dist/esm/formatters/json.js.map +0 -1
- package/dist/esm/trackers/execution.d.ts +0 -101
- package/dist/esm/trackers/execution.js +0 -226
- package/dist/esm/trackers/execution.js.map +0 -1
- package/dist/esm/trackers/index.d.ts +0 -2
- package/dist/esm/trackers/index.js +0 -3
- package/dist/esm/trackers/index.js.map +0 -1
- package/dist/esm/trackers/performance.d.ts +0 -68
- package/dist/esm/trackers/performance.js +0 -112
- package/dist/esm/trackers/performance.js.map +0 -1
- package/dist/esm/types/config.d.ts +0 -142
- package/dist/esm/types/config.js +0 -2
- package/dist/esm/types/config.js.map +0 -1
- package/dist/esm/types/logger.d.ts +0 -147
- package/dist/esm/types/logger.js +0 -2
- package/dist/esm/types/logger.js.map +0 -1
- package/dist/esm/utils/colors.d.ts +0 -87
- package/dist/esm/utils/colors.js +0 -146
- package/dist/esm/utils/colors.js.map +0 -1
- package/dist/esm/utils/index.d.ts +0 -3
- package/dist/esm/utils/index.js +0 -4
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/esm/utils/proxy-tracker.d.ts +0 -68
- package/dist/esm/utils/proxy-tracker.js +0 -127
- package/dist/esm/utils/proxy-tracker.js.map +0 -1
- package/dist/esm/utils/stack.d.ts +0 -63
- package/dist/esm/utils/stack.js +0 -110
- package/dist/esm/utils/stack.js.map +0 -1
- package/dist/esm/utils/string.d.ts +0 -29
- package/dist/esm/utils/string.js +0 -45
- package/dist/esm/utils/string.js.map +0 -1
- package/dist/esm/utils/timing.d.ts +0 -65
- package/dist/esm/utils/timing.js +0 -99
- package/dist/esm/utils/timing.js.map +0 -1
- package/dist/formatters/ascii.d.ts +0 -52
- package/dist/formatters/ascii.js +0 -104
- package/dist/formatters/ascii.js.map +0 -1
- package/dist/formatters/cli.d.ts +0 -50
- package/dist/formatters/cli.js +0 -100
- package/dist/formatters/cli.js.map +0 -1
- package/dist/formatters/index.d.ts +0 -3
- package/dist/formatters/index.js +0 -20
- package/dist/formatters/index.js.map +0 -1
- package/dist/formatters/json.d.ts +0 -45
- package/dist/formatters/json.js +0 -89
- package/dist/formatters/json.js.map +0 -1
- package/dist/trackers/execution.d.ts +0 -101
- package/dist/trackers/execution.js +0 -230
- package/dist/trackers/execution.js.map +0 -1
- package/dist/trackers/index.d.ts +0 -2
- package/dist/trackers/index.js +0 -19
- package/dist/trackers/index.js.map +0 -1
- package/dist/trackers/performance.d.ts +0 -68
- package/dist/trackers/performance.js +0 -116
- package/dist/trackers/performance.js.map +0 -1
- package/dist/types/config.d.ts +0 -142
- package/dist/types/config.js.map +0 -1
- package/dist/types/logger.d.ts +0 -147
- package/dist/types/logger.js +0 -3
- package/dist/types/logger.js.map +0 -1
- package/dist/types.d.ts +0 -65
- package/dist/types.js +0 -6
- package/dist/types.js.map +0 -1
- package/dist/utils/colors.d.ts +0 -87
- package/dist/utils/colors.js +0 -160
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.js +0 -20
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/proxy-tracker.d.ts +0 -68
- package/dist/utils/proxy-tracker.js +0 -131
- package/dist/utils/proxy-tracker.js.map +0 -1
- package/dist/utils/stack.d.ts +0 -63
- package/dist/utils/stack.js +0 -116
- package/dist/utils/stack.js.map +0 -1
- package/dist/utils/string.d.ts +0 -29
- package/dist/utils/string.js +0 -50
- package/dist/utils/string.js.map +0 -1
- package/dist/utils/timing.d.ts +0 -65
- package/dist/utils/timing.js +0 -106
- package/dist/utils/timing.js.map +0 -1
package/dist/formatters/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./cli"), exports);
|
|
18
|
-
__exportStar(require("./json"), exports);
|
|
19
|
-
__exportStar(require("./ascii"), exports);
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,yCAAuB;AACvB,0CAAwB"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { IFormatter, LogLevel, LogMeta } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* JSON formatter for structured output
|
|
4
|
-
* Formats log entries as JSON objects
|
|
5
|
-
*/
|
|
6
|
-
export declare class JsonFormatter implements IFormatter {
|
|
7
|
-
/**
|
|
8
|
-
* Format a log entry as JSON
|
|
9
|
-
*
|
|
10
|
-
* @param level - The log level
|
|
11
|
-
* @param message - The log message
|
|
12
|
-
* @param args - Additional arguments
|
|
13
|
-
* @param meta - Metadata for the log entry
|
|
14
|
-
* @returns The formatted log entry as a JSON string
|
|
15
|
-
*/
|
|
16
|
-
format(level: LogLevel, message: string | object, args: any[], meta: LogMeta): string;
|
|
17
|
-
/**
|
|
18
|
-
* Format a message for JSON output
|
|
19
|
-
*
|
|
20
|
-
* @param message - The message to format
|
|
21
|
-
* @returns The formatted message
|
|
22
|
-
*/
|
|
23
|
-
private formatMessage;
|
|
24
|
-
/**
|
|
25
|
-
* Format arguments for JSON output
|
|
26
|
-
*
|
|
27
|
-
* @param args - The arguments to format
|
|
28
|
-
* @returns The formatted arguments
|
|
29
|
-
*/
|
|
30
|
-
private formatArgs;
|
|
31
|
-
/**
|
|
32
|
-
* Sanitize an object for JSON serialization
|
|
33
|
-
*
|
|
34
|
-
* @param obj - The object to sanitize
|
|
35
|
-
* @returns A sanitized version of the object
|
|
36
|
-
*/
|
|
37
|
-
private sanitizeObject;
|
|
38
|
-
/**
|
|
39
|
-
* Extract additional metadata from the log meta object
|
|
40
|
-
*
|
|
41
|
-
* @param meta - The log metadata
|
|
42
|
-
* @returns Additional metadata as an object
|
|
43
|
-
*/
|
|
44
|
-
private extractExtraMeta;
|
|
45
|
-
}
|
package/dist/formatters/json.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JsonFormatter = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* JSON formatter for structured output
|
|
6
|
-
* Formats log entries as JSON objects
|
|
7
|
-
*/
|
|
8
|
-
class JsonFormatter {
|
|
9
|
-
/**
|
|
10
|
-
* Format a log entry as JSON
|
|
11
|
-
*
|
|
12
|
-
* @param level - The log level
|
|
13
|
-
* @param message - The log message
|
|
14
|
-
* @param args - Additional arguments
|
|
15
|
-
* @param meta - Metadata for the log entry
|
|
16
|
-
* @returns The formatted log entry as a JSON string
|
|
17
|
-
*/
|
|
18
|
-
format(level, message, args, meta) {
|
|
19
|
-
const logEntry = {
|
|
20
|
-
timestamp: meta.timestamp.toISOString(),
|
|
21
|
-
level,
|
|
22
|
-
indentLevel: meta.indentLevel,
|
|
23
|
-
message: this.formatMessage(message),
|
|
24
|
-
args: this.formatArgs(args),
|
|
25
|
-
...this.extractExtraMeta(meta),
|
|
26
|
-
};
|
|
27
|
-
return JSON.stringify(logEntry);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Format a message for JSON output
|
|
31
|
-
*
|
|
32
|
-
* @param message - The message to format
|
|
33
|
-
* @returns The formatted message
|
|
34
|
-
*/
|
|
35
|
-
formatMessage(message) {
|
|
36
|
-
if (typeof message === 'string') {
|
|
37
|
-
return message;
|
|
38
|
-
}
|
|
39
|
-
return this.sanitizeObject(message);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Format arguments for JSON output
|
|
43
|
-
*
|
|
44
|
-
* @param args - The arguments to format
|
|
45
|
-
* @returns The formatted arguments
|
|
46
|
-
*/
|
|
47
|
-
formatArgs(args) {
|
|
48
|
-
return args.map(arg => {
|
|
49
|
-
if (typeof arg === 'object' && arg !== null) {
|
|
50
|
-
return this.sanitizeObject(arg);
|
|
51
|
-
}
|
|
52
|
-
return arg;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Sanitize an object for JSON serialization
|
|
57
|
-
*
|
|
58
|
-
* @param obj - The object to sanitize
|
|
59
|
-
* @returns A sanitized version of the object
|
|
60
|
-
*/
|
|
61
|
-
sanitizeObject(obj) {
|
|
62
|
-
try {
|
|
63
|
-
// Use JSON.parse(JSON.stringify()) to remove non-serializable values
|
|
64
|
-
return JSON.parse(JSON.stringify(obj));
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
// If serialization fails, return a simplified object
|
|
68
|
-
return { value: String(obj) };
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Extract additional metadata from the log meta object
|
|
73
|
-
*
|
|
74
|
-
* @param meta - The log metadata
|
|
75
|
-
* @returns Additional metadata as an object
|
|
76
|
-
*/
|
|
77
|
-
extractExtraMeta(meta) {
|
|
78
|
-
const result = {};
|
|
79
|
-
// Copy all properties except the standard ones
|
|
80
|
-
Object.keys(meta).forEach(key => {
|
|
81
|
-
if (!['timestamp', 'level', 'indentLevel'].includes(key)) {
|
|
82
|
-
result[key] = meta[key];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.JsonFormatter = JsonFormatter;
|
|
89
|
-
//# sourceMappingURL=json.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/formatters/json.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,MAAa,aAAa;IACxB;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAe,EAAE,OAAwB,EAAE,IAAW,EAAE,IAAa;QACjF,MAAM,QAAQ,GAAG;YACf,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;YACvC,KAAK;YACL,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;YACpC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAC3B,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;SAC/B,CAAC;QAEF,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACK,aAAa,CAAC,OAAwB;QAC5C,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED;;;;;OAKG;IACK,UAAU,CAAC,IAAW;QAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACpB,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;gBAC5C,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACK,cAAc,CAAC,GAAW;QAChC,IAAI,CAAC;YACH,qEAAqE;YACrE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,qDAAqD;YACrD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACK,gBAAgB,CAAC,IAAa;QACpC,MAAM,MAAM,GAAwB,EAAE,CAAC;QAEvC,+CAA+C;QAC/C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC9B,IAAI,CAAC,CAAC,WAAW,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzD,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAtFD,sCAsFC"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { IExecutionTracker, ITrackOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* A record of a function execution
|
|
4
|
-
*/
|
|
5
|
-
export interface ExecutionRecord {
|
|
6
|
-
name: string;
|
|
7
|
-
duration: number;
|
|
8
|
-
startTime: [number, number];
|
|
9
|
-
endTime?: [number, number];
|
|
10
|
-
isSlow: boolean;
|
|
11
|
-
level: number;
|
|
12
|
-
memoryUsage?: number;
|
|
13
|
-
memoryReleased?: number;
|
|
14
|
-
children: ExecutionRecord[];
|
|
15
|
-
parent?: ExecutionRecord;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Execution tracker for performance monitoring
|
|
19
|
-
*/
|
|
20
|
-
export declare class ExecutionTracker implements IExecutionTracker {
|
|
21
|
-
private _executions;
|
|
22
|
-
private _currentExecution;
|
|
23
|
-
private _defaultThreshold;
|
|
24
|
-
private _callStack;
|
|
25
|
-
private _globalScope;
|
|
26
|
-
private _trackedFunctions;
|
|
27
|
-
/**
|
|
28
|
-
* Constructor
|
|
29
|
-
*
|
|
30
|
-
* @param options - Options for execution tracking
|
|
31
|
-
*/
|
|
32
|
-
constructor(options?: {
|
|
33
|
-
defaultThreshold?: number;
|
|
34
|
-
});
|
|
35
|
-
/**
|
|
36
|
-
* Track the execution of a function
|
|
37
|
-
*
|
|
38
|
-
* @param fn - The function to track
|
|
39
|
-
* @param options - Options for tracking
|
|
40
|
-
* @returns The return value of the tracked function
|
|
41
|
-
*/
|
|
42
|
-
track<T>(fn: () => T, options?: ITrackOptions): T;
|
|
43
|
-
/**
|
|
44
|
-
* Create a trackable version of a function
|
|
45
|
-
*
|
|
46
|
-
* This is a helper method to create a tracked version of a function
|
|
47
|
-
* that can be used for nested function tracking.
|
|
48
|
-
*
|
|
49
|
-
* @param fn - The function to make trackable
|
|
50
|
-
* @param options - Options for tracking
|
|
51
|
-
* @returns A tracked version of the function
|
|
52
|
-
*/
|
|
53
|
-
createTrackable<T extends (...args: any[]) => any>(fn: T, options?: Omit<ITrackOptions, 'label'> & {
|
|
54
|
-
label?: string;
|
|
55
|
-
}): (...args: Parameters<T>) => ReturnType<T>;
|
|
56
|
-
/**
|
|
57
|
-
* Get all execution records
|
|
58
|
-
*
|
|
59
|
-
* @returns A list of execution records
|
|
60
|
-
*/
|
|
61
|
-
getExecutions(): ExecutionRecord[];
|
|
62
|
-
/**
|
|
63
|
-
* Generate a human-friendly memory size string
|
|
64
|
-
*
|
|
65
|
-
* @param bytes - The size in bytes
|
|
66
|
-
* @returns A formatted string
|
|
67
|
-
*/
|
|
68
|
-
formatMemorySize(bytes: number): string;
|
|
69
|
-
/**
|
|
70
|
-
* Get the current call stack
|
|
71
|
-
*
|
|
72
|
-
* @returns The current call stack
|
|
73
|
-
*/
|
|
74
|
-
getCallStack(): string[];
|
|
75
|
-
/**
|
|
76
|
-
* Generate a visual representation of the execution flow
|
|
77
|
-
*
|
|
78
|
-
* @returns ASCII flow chart of the execution
|
|
79
|
-
*/
|
|
80
|
-
generateFlowChart(): string;
|
|
81
|
-
/**
|
|
82
|
-
* Recursively print an execution tree
|
|
83
|
-
*
|
|
84
|
-
* @param execution - The root execution
|
|
85
|
-
* @param result - The output string
|
|
86
|
-
* @returns The updated result string
|
|
87
|
-
*/
|
|
88
|
-
private printExecutionTree;
|
|
89
|
-
/**
|
|
90
|
-
* Print a single execution with appropriate formatting
|
|
91
|
-
*
|
|
92
|
-
* @param execution - The execution to print
|
|
93
|
-
* @param result - The result string to append to
|
|
94
|
-
* @returns The updated result string
|
|
95
|
-
*/
|
|
96
|
-
private printSingleExecution;
|
|
97
|
-
/**
|
|
98
|
-
* Clear all execution records
|
|
99
|
-
*/
|
|
100
|
-
clear(): void;
|
|
101
|
-
}
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExecutionTracker = void 0;
|
|
4
|
-
const stack_1 = require("../utils/stack");
|
|
5
|
-
const timing_1 = require("../utils/timing");
|
|
6
|
-
/**
|
|
7
|
-
* Execution tracker for performance monitoring
|
|
8
|
-
*/
|
|
9
|
-
class ExecutionTracker {
|
|
10
|
-
/**
|
|
11
|
-
* Constructor
|
|
12
|
-
*
|
|
13
|
-
* @param options - Options for execution tracking
|
|
14
|
-
*/
|
|
15
|
-
constructor(options = {}) {
|
|
16
|
-
var _a;
|
|
17
|
-
this._executions = [];
|
|
18
|
-
this._currentExecution = null;
|
|
19
|
-
this._callStack = [];
|
|
20
|
-
this._trackedFunctions = new Map();
|
|
21
|
-
this._defaultThreshold = (_a = options.defaultThreshold) !== null && _a !== void 0 ? _a : 100; // ms
|
|
22
|
-
// Get a reference to the global scope (works in both Node.js and browsers)
|
|
23
|
-
this._globalScope = typeof window !== 'undefined' ? window :
|
|
24
|
-
typeof global !== 'undefined' ? global :
|
|
25
|
-
{};
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Track the execution of a function
|
|
29
|
-
*
|
|
30
|
-
* @param fn - The function to track
|
|
31
|
-
* @param options - Options for tracking
|
|
32
|
-
* @returns The return value of the tracked function
|
|
33
|
-
*/
|
|
34
|
-
track(fn, options) {
|
|
35
|
-
var _a, _b, _c;
|
|
36
|
-
const fnName = (options === null || options === void 0 ? void 0 : options.label) || (0, stack_1.getFunctionName)(fn);
|
|
37
|
-
const threshold = (_a = options === null || options === void 0 ? void 0 : options.threshold) !== null && _a !== void 0 ? _a : this._defaultThreshold;
|
|
38
|
-
const includeMemory = (_b = options === null || options === void 0 ? void 0 : options.trackMemory) !== null && _b !== void 0 ? _b : true;
|
|
39
|
-
const enableNestedTracking = (_c = options === null || options === void 0 ? void 0 : options.enableNestedTracking) !== null && _c !== void 0 ? _c : true;
|
|
40
|
-
// Get memory usage before execution
|
|
41
|
-
let startMemory;
|
|
42
|
-
if (includeMemory) {
|
|
43
|
-
try {
|
|
44
|
-
startMemory = process.memoryUsage();
|
|
45
|
-
}
|
|
46
|
-
catch (e) {
|
|
47
|
-
console.warn('Unable to track memory usage:', e);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// Start timing
|
|
51
|
-
const startTime = (0, timing_1.getHighResTime)();
|
|
52
|
-
// Add to call stack
|
|
53
|
-
const level = this._callStack.push(fnName);
|
|
54
|
-
// Create execution record
|
|
55
|
-
const execution = {
|
|
56
|
-
name: fnName,
|
|
57
|
-
duration: 0,
|
|
58
|
-
isSlow: false,
|
|
59
|
-
level: level - 1, // 0-based level
|
|
60
|
-
startTime,
|
|
61
|
-
children: [],
|
|
62
|
-
};
|
|
63
|
-
// Set parent-child relationship
|
|
64
|
-
if (this._currentExecution && enableNestedTracking) {
|
|
65
|
-
execution.parent = this._currentExecution;
|
|
66
|
-
this._currentExecution.children.push(execution);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
// This is a root execution
|
|
70
|
-
this._executions.push(execution);
|
|
71
|
-
}
|
|
72
|
-
// Save the previous current execution
|
|
73
|
-
const previousExecution = this._currentExecution;
|
|
74
|
-
// Set this as the current execution
|
|
75
|
-
this._currentExecution = execution;
|
|
76
|
-
try {
|
|
77
|
-
// Execute the function
|
|
78
|
-
return fn();
|
|
79
|
-
}
|
|
80
|
-
finally {
|
|
81
|
-
// End timing
|
|
82
|
-
const endTime = (0, timing_1.getHighResTime)();
|
|
83
|
-
execution.endTime = endTime;
|
|
84
|
-
// Calculate duration
|
|
85
|
-
execution.duration = (0, timing_1.getDuration)(startTime);
|
|
86
|
-
// Check if it's a bottleneck
|
|
87
|
-
execution.isSlow = execution.duration > threshold;
|
|
88
|
-
// Calculate memory usage
|
|
89
|
-
if (includeMemory && startMemory !== undefined) {
|
|
90
|
-
try {
|
|
91
|
-
const endMemory = process.memoryUsage();
|
|
92
|
-
// Calculate the memory difference, ensuring it's never negative
|
|
93
|
-
const memoryDiff = endMemory.heapUsed - startMemory.heapUsed;
|
|
94
|
-
execution.memoryUsage = Math.max(0, memoryDiff); // Ensure non-negative value
|
|
95
|
-
// If memory decreased, store a separate field for better visualization
|
|
96
|
-
if (memoryDiff < 0) {
|
|
97
|
-
execution.memoryReleased = Math.abs(memoryDiff);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
catch (e) {
|
|
101
|
-
console.warn('Error calculating memory usage:', e);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
// Restore the previous current execution
|
|
105
|
-
this._currentExecution = previousExecution;
|
|
106
|
-
// Remove from call stack
|
|
107
|
-
this._callStack.pop();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Create a trackable version of a function
|
|
112
|
-
*
|
|
113
|
-
* This is a helper method to create a tracked version of a function
|
|
114
|
-
* that can be used for nested function tracking.
|
|
115
|
-
*
|
|
116
|
-
* @param fn - The function to make trackable
|
|
117
|
-
* @param options - Options for tracking
|
|
118
|
-
* @returns A tracked version of the function
|
|
119
|
-
*/
|
|
120
|
-
createTrackable(fn, options) {
|
|
121
|
-
const fnName = (options === null || options === void 0 ? void 0 : options.label) || fn.name || 'anonymous';
|
|
122
|
-
// Create a tracked version of the function using arrow function to preserve 'this'
|
|
123
|
-
const trackedFn = (...args) => {
|
|
124
|
-
return this.track(() => fn.apply(this, args), {
|
|
125
|
-
...options,
|
|
126
|
-
label: fnName
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
|
-
// Store the original and tracked function
|
|
130
|
-
this._trackedFunctions.set(fn, trackedFn);
|
|
131
|
-
return trackedFn;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Get all execution records
|
|
135
|
-
*
|
|
136
|
-
* @returns A list of execution records
|
|
137
|
-
*/
|
|
138
|
-
getExecutions() {
|
|
139
|
-
return [...this._executions];
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Generate a human-friendly memory size string
|
|
143
|
-
*
|
|
144
|
-
* @param bytes - The size in bytes
|
|
145
|
-
* @returns A formatted string
|
|
146
|
-
*/
|
|
147
|
-
formatMemorySize(bytes) {
|
|
148
|
-
if (bytes < 1024) {
|
|
149
|
-
return `${bytes.toFixed(2)}B`;
|
|
150
|
-
}
|
|
151
|
-
else if (bytes < 1024 * 1024) {
|
|
152
|
-
return `${(bytes / 1024).toFixed(2)}KB`;
|
|
153
|
-
}
|
|
154
|
-
else if (bytes < 1024 * 1024 * 1024) {
|
|
155
|
-
return `${(bytes / (1024 * 1024)).toFixed(2)}MB`;
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)}GB`;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Get the current call stack
|
|
163
|
-
*
|
|
164
|
-
* @returns The current call stack
|
|
165
|
-
*/
|
|
166
|
-
getCallStack() {
|
|
167
|
-
return [...this._callStack];
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Generate a visual representation of the execution flow
|
|
171
|
-
*
|
|
172
|
-
* @returns ASCII flow chart of the execution
|
|
173
|
-
*/
|
|
174
|
-
generateFlowChart() {
|
|
175
|
-
let result = '';
|
|
176
|
-
// Process each execution
|
|
177
|
-
this._executions.forEach(execution => {
|
|
178
|
-
result = this.printExecutionTree(execution, result);
|
|
179
|
-
});
|
|
180
|
-
return result;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Recursively print an execution tree
|
|
184
|
-
*
|
|
185
|
-
* @param execution - The root execution
|
|
186
|
-
* @param result - The output string
|
|
187
|
-
* @returns The updated result string
|
|
188
|
-
*/
|
|
189
|
-
printExecutionTree(execution, result) {
|
|
190
|
-
// Print this execution
|
|
191
|
-
result = this.printSingleExecution(execution, result);
|
|
192
|
-
// Print children recursively
|
|
193
|
-
execution.children.forEach(child => {
|
|
194
|
-
result = this.printExecutionTree(child, result);
|
|
195
|
-
});
|
|
196
|
-
return result;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Print a single execution with appropriate formatting
|
|
200
|
-
*
|
|
201
|
-
* @param execution - The execution to print
|
|
202
|
-
* @param result - The result string to append to
|
|
203
|
-
* @returns The updated result string
|
|
204
|
-
*/
|
|
205
|
-
printSingleExecution(execution, result) {
|
|
206
|
-
const indent = ' '.repeat(execution.level);
|
|
207
|
-
const durationStr = execution.duration.toFixed(2);
|
|
208
|
-
const slowMarker = execution.isSlow ? ' [SLOW]' : '';
|
|
209
|
-
let memoryStr = '';
|
|
210
|
-
if (execution.memoryUsage !== undefined) {
|
|
211
|
-
memoryStr = ` [${this.formatMemorySize(execution.memoryUsage)}]`;
|
|
212
|
-
}
|
|
213
|
-
result += `${indent}→ ${execution.name} (${durationStr}ms)${slowMarker}${memoryStr}\n`;
|
|
214
|
-
// Add connector if this execution has children
|
|
215
|
-
if (execution.children.length > 0) {
|
|
216
|
-
result += `${indent} |\n`;
|
|
217
|
-
}
|
|
218
|
-
return result;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Clear all execution records
|
|
222
|
-
*/
|
|
223
|
-
clear() {
|
|
224
|
-
this._executions = [];
|
|
225
|
-
this._currentExecution = null;
|
|
226
|
-
this._callStack = [];
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
exports.ExecutionTracker = ExecutionTracker;
|
|
230
|
-
//# sourceMappingURL=execution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/trackers/execution.ts"],"names":[],"mappings":";;;AACA,0CAAiD;AACjD,4CAA8E;AAkB9E;;GAEG;AACH,MAAa,gBAAgB;IAQ3B;;;;OAIG;IACH,YAAY,UAAyC,EAAE;;QAZ/C,gBAAW,GAAsB,EAAE,CAAC;QACpC,sBAAiB,GAA2B,IAAI,CAAC;QAEjD,eAAU,GAAa,EAAE,CAAC;QAE1B,sBAAiB,GAA4B,IAAI,GAAG,EAAE,CAAC;QAQ7D,IAAI,CAAC,iBAAiB,GAAG,MAAA,OAAO,CAAC,gBAAgB,mCAAI,GAAG,CAAC,CAAC,KAAK;QAE/D,2EAA2E;QAC3E,IAAI,CAAC,YAAY,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YACxC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAE,MAAyC,CAAC,CAAC;gBAC5E,EAAyB,CAAC;IAChD,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAI,EAAW,EAAE,OAAuB;;QAClD,MAAM,MAAM,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,KAAI,IAAA,uBAAe,EAAC,EAAE,CAAC,CAAC;QACrD,MAAM,SAAS,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,mCAAI,IAAI,CAAC,iBAAiB,CAAC;QAC/D,MAAM,aAAa,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO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AAW,MAAM,UAAU,GAAG,SAAS,IAAI,CAAC;QAEvF,+CAA+C;QAC/C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC;QAC7B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,KAAK;QACV,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;CACF;AA3PD,4CA2PC"}
|
package/dist/trackers/index.d.ts
DELETED
package/dist/trackers/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./execution"), exports);
|
|
18
|
-
__exportStar(require("./performance"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/trackers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,gDAA8B"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { IPerformanceMonitor } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Performance monitor for tracking execution times and memory usage
|
|
4
|
-
*/
|
|
5
|
-
export declare class PerformanceMonitor implements IPerformanceMonitor {
|
|
6
|
-
private _timers;
|
|
7
|
-
private _defaultThreshold;
|
|
8
|
-
/**
|
|
9
|
-
* Create a new PerformanceMonitor instance
|
|
10
|
-
*
|
|
11
|
-
* @param options - Monitor options
|
|
12
|
-
*/
|
|
13
|
-
constructor(options?: {
|
|
14
|
-
defaultThreshold?: number;
|
|
15
|
-
});
|
|
16
|
-
/**
|
|
17
|
-
* Start timing an operation
|
|
18
|
-
*
|
|
19
|
-
* @param label - Label for the operation
|
|
20
|
-
* @returns A unique identifier for the timing operation
|
|
21
|
-
*/
|
|
22
|
-
startTimer(label: string): string;
|
|
23
|
-
/**
|
|
24
|
-
* End timing an operation
|
|
25
|
-
*
|
|
26
|
-
* @param id - The identifier returned by startTimer
|
|
27
|
-
* @returns The duration in milliseconds
|
|
28
|
-
* @throws Error if the timer doesn't exist
|
|
29
|
-
*/
|
|
30
|
-
endTimer(id: string): number;
|
|
31
|
-
/**
|
|
32
|
-
* Check if an operation exceeds the performance threshold
|
|
33
|
-
*
|
|
34
|
-
* @param duration - The duration in milliseconds
|
|
35
|
-
* @param threshold - The threshold to check against
|
|
36
|
-
* @returns Whether the operation is considered slow
|
|
37
|
-
*/
|
|
38
|
-
isBottleneck(duration: number, threshold?: number): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Get memory usage information
|
|
41
|
-
*
|
|
42
|
-
* @returns Memory usage object
|
|
43
|
-
*/
|
|
44
|
-
getMemoryUsage(): {
|
|
45
|
-
heapUsed: number;
|
|
46
|
-
heapTotal: number;
|
|
47
|
-
external: number;
|
|
48
|
-
rss: number;
|
|
49
|
-
} | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* Calculate memory difference between current and start memory
|
|
52
|
-
*
|
|
53
|
-
* @param start - Starting memory usage snapshot
|
|
54
|
-
* @returns Memory difference or undefined
|
|
55
|
-
*/
|
|
56
|
-
getMemoryDiff(start: {
|
|
57
|
-
heapUsed: number;
|
|
58
|
-
}): number;
|
|
59
|
-
/**
|
|
60
|
-
* Generate a suggestion for a bottleneck
|
|
61
|
-
*
|
|
62
|
-
* @param functionName - The name of the function
|
|
63
|
-
* @param duration - The duration in milliseconds
|
|
64
|
-
* @param memoryUsage - Memory usage in bytes
|
|
65
|
-
* @returns A suggestion for improving performance
|
|
66
|
-
*/
|
|
67
|
-
generateSuggestion(functionName: string, duration: number, memoryUsage?: number): string;
|
|
68
|
-
}
|