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
|
@@ -39,37 +39,23 @@ export declare class PerformanceMonitor implements IPerformanceMonitor {
|
|
|
39
39
|
/**
|
|
40
40
|
* Get memory usage information
|
|
41
41
|
*
|
|
42
|
-
* @returns Memory usage
|
|
42
|
+
* @returns Memory usage object
|
|
43
43
|
*/
|
|
44
44
|
getMemoryUsage(): {
|
|
45
45
|
heapUsed: number;
|
|
46
46
|
heapTotal: number;
|
|
47
47
|
external: number;
|
|
48
48
|
rss: number;
|
|
49
|
-
};
|
|
49
|
+
} | undefined;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* Calculate memory difference between current and start memory
|
|
52
52
|
*
|
|
53
|
-
* @param
|
|
54
|
-
* @
|
|
55
|
-
* @returns Memory difference in bytes
|
|
53
|
+
* @param start - Starting memory usage snapshot
|
|
54
|
+
* @returns Memory difference or undefined
|
|
56
55
|
*/
|
|
57
|
-
getMemoryDiff(
|
|
56
|
+
getMemoryDiff(start: {
|
|
58
57
|
heapUsed: number;
|
|
59
|
-
|
|
60
|
-
external: number;
|
|
61
|
-
rss: number;
|
|
62
|
-
}, after: {
|
|
63
|
-
heapUsed: number;
|
|
64
|
-
heapTotal: number;
|
|
65
|
-
external: number;
|
|
66
|
-
rss: number;
|
|
67
|
-
}): {
|
|
68
|
-
heapUsed: number;
|
|
69
|
-
heapTotal: number;
|
|
70
|
-
external: number;
|
|
71
|
-
rss: number;
|
|
72
|
-
};
|
|
58
|
+
}): number;
|
|
73
59
|
/**
|
|
74
60
|
* Generate a suggestion for a bottleneck
|
|
75
61
|
*
|
|
@@ -58,31 +58,37 @@ class PerformanceMonitor {
|
|
|
58
58
|
/**
|
|
59
59
|
* Get memory usage information
|
|
60
60
|
*
|
|
61
|
-
* @returns Memory usage
|
|
61
|
+
* @returns Memory usage object
|
|
62
62
|
*/
|
|
63
63
|
getMemoryUsage() {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
64
|
+
try {
|
|
65
|
+
return process.memoryUsage();
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
console.warn('Unable to track memory usage:', e);
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
73
|
+
* Calculate memory difference between current and start memory
|
|
74
74
|
*
|
|
75
|
-
* @param
|
|
76
|
-
* @
|
|
77
|
-
* @returns Memory difference in bytes
|
|
75
|
+
* @param start - Starting memory usage snapshot
|
|
76
|
+
* @returns Memory difference or undefined
|
|
78
77
|
*/
|
|
79
|
-
getMemoryDiff(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
getMemoryDiff(start) {
|
|
79
|
+
try {
|
|
80
|
+
const current = this.getMemoryUsage();
|
|
81
|
+
if (!current)
|
|
82
|
+
return 0;
|
|
83
|
+
const diff = current.heapUsed - start.heapUsed;
|
|
84
|
+
// Return zero instead of negative values
|
|
85
|
+
// Negative values usually indicate garbage collection, not actual memory release
|
|
86
|
+
return Math.max(0, diff);
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
console.warn('Error calculating memory usage:', e);
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
86
92
|
}
|
|
87
93
|
/**
|
|
88
94
|
* Generate a suggestion for a bottleneck
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"performance.js","sourceRoot":"","sources":["../../src/trackers/performance.ts"],"names":[],"mappings":";;;AACA,4CAA8D;AAC9D,+BAAoC;AAEpC;;GAEG;AACH,MAAa,kBAAkB;IAI7B;;;;OAIG;IACH,YAAY,UAAyC,EAAE;;QAR/C,YAAO,GAAkC,IAAI,GAAG,EAAE,CAAC;QASzD,IAAI,CAAC,iBAAiB,GAAG,MAAA,OAAO,CAAC,gBAAgB,mCAAI,GAAG,CAAC,CAAC,KAAK;IACjE,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,KAAa;QAC7B,MAAM,EAAE,GAAG,GAAG,KAAK,IAAI,IAAA,SAAM,GAAE,EAAE,CAAC;QAClC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,IAAA,uBAAc,GAAE,CAAC,CAAC;QACvC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;;;;;OAMG;IACI,QAAQ,CAAC,EAAU;QACxB,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,QAAQ,GAAG,IAAA,oBAAW,EAAC,SAAS,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAExB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACI,YAAY,CAAC,QAAgB,EAAE,SAAkB;QACtD,MAAM,kBAAkB,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,iBAAiB,CAAC;QAC/D,OAAO,QAAQ,GAAG,kBAAkB,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACI,cAAc;QACnB,
|
|
1
|
+
{"version":3,"file":"performance.js","sourceRoot":"","sources":["../../src/trackers/performance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C,IAAI,CAAC,+BAA+B,EAAE,CAAC,CAAC,CAAC;YACjD,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,aAAa,CAAC,KAA2B;QAC9C,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YACtC,IAAI,CAAC,OAAO;gBAAE,OAAO,CAAC,CAAC;YAEvB,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;YAE/C,yCAAyC;YACzC,iFAAiF;YACjF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,IAAI,CAAC,iCAAiC,EAAE,CAAC,CAAC,CAAC;YACnD,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACI,kBAAkB,CACvB,YAAoB,EACpB,QAAgB,EAChB,WAAoB;QAEpB,qCAAqC;QACrC,IAAI,WAAW,IAAI,WAAW,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;YAClD,OAAO,2EAA2E,YAAY,EAAE,CAAC;QACnG,CAAC;QAED,IAAI,QAAQ,GAAG,IAAI,EAAE,CAAC;YACpB,OAAO,8DAA8D,YAAY,EAAE,CAAC;QACtF,CAAC;QAED,IAAI,QAAQ,GAAG,GAAG,EAAE,CAAC;YACnB,OAAO,qDAAqD,YAAY,EAAE,CAAC;QAC7E,CAAC;QAED,OAAO,4BAA4B,YAAY,gCAAgC,CAAC;IAClF,CAAC;CACF;AAxHD,gDAwHC"}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -55,9 +55,9 @@ export interface ITrackOptions {
|
|
|
55
55
|
*/
|
|
56
56
|
threshold?: number;
|
|
57
57
|
/**
|
|
58
|
-
* Whether to
|
|
58
|
+
* Whether to track memory usage
|
|
59
59
|
*/
|
|
60
|
-
|
|
60
|
+
trackMemory?: boolean;
|
|
61
61
|
/**
|
|
62
62
|
* Whether to suppress logging for this tracking
|
|
63
63
|
*/
|
|
@@ -71,6 +71,15 @@ export interface ITrackOptions {
|
|
|
71
71
|
* @default true
|
|
72
72
|
*/
|
|
73
73
|
enableNestedTracking?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Tracking mode to use for this function
|
|
76
|
+
* Controls the level of detail and performance impact
|
|
77
|
+
*/
|
|
78
|
+
trackingMode?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Any other custom options
|
|
81
|
+
*/
|
|
82
|
+
[key: string]: any;
|
|
74
83
|
}
|
|
75
84
|
/**
|
|
76
85
|
* Logger configuration
|
|
@@ -125,4 +134,9 @@ export interface ILoggerConfig {
|
|
|
125
134
|
* @default [CliFormatter]
|
|
126
135
|
*/
|
|
127
136
|
formatters?: IFormatter[];
|
|
137
|
+
/**
|
|
138
|
+
* Tracking mode to use for performance monitoring
|
|
139
|
+
* Controls the level of detail and performance impact
|
|
140
|
+
*/
|
|
141
|
+
trackingMode?: string;
|
|
128
142
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,44 +1,42 @@
|
|
|
1
1
|
export * from './config';
|
|
2
2
|
export * from './logger';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Interface for TracePerf configuration
|
|
5
|
+
*/
|
|
6
|
+
export interface ITracePerfConfig {
|
|
7
|
+
/** Tracking mode for balancing performance vs detail */
|
|
8
|
+
trackingMode?: string;
|
|
9
|
+
/** Whether to suppress console output */
|
|
10
|
+
silent?: boolean;
|
|
11
|
+
/** Whether to track memory usage */
|
|
12
|
+
trackMemory?: boolean;
|
|
13
|
+
/** Whether to enable nested function tracking */
|
|
14
|
+
enableNestedTracking?: boolean;
|
|
15
|
+
/** Minimum duration threshold in microseconds */
|
|
16
|
+
threshold?: number;
|
|
17
|
+
/** Sampling rate (0.0-1.0) for reducing overhead */
|
|
18
|
+
sampleRate?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Interface for tracking options
|
|
5
22
|
*/
|
|
6
23
|
export interface ITrackOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Custom label for the function
|
|
9
|
-
*/
|
|
24
|
+
/** Custom label for the tracked function */
|
|
10
25
|
label?: string;
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
threshold?: number;
|
|
15
|
-
/**
|
|
16
|
-
* Whether to include memory usage in the tracking
|
|
17
|
-
*/
|
|
18
|
-
includeMemory?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Whether to track nested function calls
|
|
21
|
-
*
|
|
22
|
-
* Note: With automatic tracking enabled, TracePerf will attempt to
|
|
23
|
-
* automatically detect and track nested function calls without requiring
|
|
24
|
-
* manual tracking of each function.
|
|
25
|
-
*
|
|
26
|
-
* @default true
|
|
27
|
-
*/
|
|
28
|
-
enableNestedTracking?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Whether to automatically track nested function calls
|
|
31
|
-
*
|
|
32
|
-
* When enabled, TracePerf will analyze the function source code to identify
|
|
33
|
-
* potential function calls and automatically track them.
|
|
34
|
-
*
|
|
35
|
-
* @default true
|
|
36
|
-
*/
|
|
37
|
-
autoTracking?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Whether to suppress logging
|
|
40
|
-
*/
|
|
26
|
+
/** Override default tracking mode */
|
|
27
|
+
trackingMode?: string;
|
|
28
|
+
/** Override default silent setting */
|
|
41
29
|
silent?: boolean;
|
|
30
|
+
/** Override default memory tracking */
|
|
31
|
+
trackMemory?: boolean;
|
|
32
|
+
/** Override default nested tracking */
|
|
33
|
+
enableNestedTracking?: boolean;
|
|
34
|
+
/** Minimum duration threshold in microseconds */
|
|
35
|
+
threshold?: number;
|
|
36
|
+
/** Sampling rate (0.0-1.0) for reducing overhead */
|
|
37
|
+
sampleRate?: number;
|
|
38
|
+
/** Any other options */
|
|
39
|
+
[key: string]: any;
|
|
42
40
|
}
|
|
43
41
|
/**
|
|
44
42
|
* Interface for execution trackers
|
package/dist/types/logger.d.ts
CHANGED
|
@@ -127,12 +127,21 @@ export interface IPerformanceMonitor {
|
|
|
127
127
|
/**
|
|
128
128
|
* Get memory usage information
|
|
129
129
|
*
|
|
130
|
-
* @returns Memory usage
|
|
130
|
+
* @returns Memory usage object or undefined if not available
|
|
131
131
|
*/
|
|
132
132
|
getMemoryUsage(): {
|
|
133
133
|
heapUsed: number;
|
|
134
134
|
heapTotal: number;
|
|
135
135
|
external: number;
|
|
136
136
|
rss: number;
|
|
137
|
-
};
|
|
137
|
+
} | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Calculate memory difference between current and start memory
|
|
140
|
+
*
|
|
141
|
+
* @param start - Starting memory usage snapshot
|
|
142
|
+
* @returns Memory difference in bytes
|
|
143
|
+
*/
|
|
144
|
+
getMemoryDiff(start: {
|
|
145
|
+
heapUsed: number;
|
|
146
|
+
}): number;
|
|
138
147
|
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module for defining common types used throughout the application
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Options for tracking function execution
|
|
6
|
+
*/
|
|
7
|
+
export interface ITrackOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Custom label for the function
|
|
10
|
+
*/
|
|
11
|
+
label?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Threshold in milliseconds for slow function detection
|
|
14
|
+
*/
|
|
15
|
+
threshold?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Whether to include memory usage in the tracking
|
|
18
|
+
*/
|
|
19
|
+
includeMemory?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether to enable nested function tracking
|
|
22
|
+
* If true, functions called within the tracked function will also be tracked
|
|
23
|
+
* Default: true
|
|
24
|
+
*/
|
|
25
|
+
enableNestedTracking?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Interface for execution trackers
|
|
29
|
+
*/
|
|
30
|
+
export interface IExecutionTracker {
|
|
31
|
+
/**
|
|
32
|
+
* Track the execution of a function
|
|
33
|
+
*
|
|
34
|
+
* @param fn - The function to track
|
|
35
|
+
* @param options - Options for tracking
|
|
36
|
+
* @returns The return value of the tracked function
|
|
37
|
+
*/
|
|
38
|
+
track<T>(fn: () => T, options?: ITrackOptions): T;
|
|
39
|
+
/**
|
|
40
|
+
* Create a trackable version of a function
|
|
41
|
+
*
|
|
42
|
+
* @param fn - The function to make trackable
|
|
43
|
+
* @param options - Options for tracking
|
|
44
|
+
* @returns A tracked version of the function
|
|
45
|
+
*/
|
|
46
|
+
createTrackable<T extends (...args: any[]) => any>(fn: T, options?: Omit<ITrackOptions, 'label'> & {
|
|
47
|
+
label?: string;
|
|
48
|
+
}): (...args: Parameters<T>) => ReturnType<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Get the current call stack
|
|
51
|
+
*
|
|
52
|
+
* @returns The current call stack
|
|
53
|
+
*/
|
|
54
|
+
getCallStack(): string[];
|
|
55
|
+
/**
|
|
56
|
+
* Generate a visual representation of the execution flow
|
|
57
|
+
*
|
|
58
|
+
* @returns ASCII flow chart of the execution
|
|
59
|
+
*/
|
|
60
|
+
generateFlowChart(): string;
|
|
61
|
+
/**
|
|
62
|
+
* Clear all execution records
|
|
63
|
+
*/
|
|
64
|
+
clear(): void;
|
|
65
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
package/dist/utils/colors.js
CHANGED
|
@@ -24,6 +24,9 @@ const constants_1 = require("../core/constants");
|
|
|
24
24
|
* @returns The colorized string
|
|
25
25
|
*/
|
|
26
26
|
function colorize(text, color) {
|
|
27
|
+
if (typeof supportsColor === 'function' ? !supportsColor() : false) {
|
|
28
|
+
return text;
|
|
29
|
+
}
|
|
27
30
|
return `${color}${text}${constants_1.COLORS.reset}`;
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
@@ -33,6 +36,9 @@ function colorize(text, color) {
|
|
|
33
36
|
* @returns The bold string
|
|
34
37
|
*/
|
|
35
38
|
function bold(text) {
|
|
39
|
+
if (typeof supportsColor === 'function' ? !supportsColor() : false) {
|
|
40
|
+
return text;
|
|
41
|
+
}
|
|
36
42
|
return `${constants_1.COLORS.bright}${text}${constants_1.COLORS.reset}`;
|
|
37
43
|
}
|
|
38
44
|
/**
|
|
@@ -42,6 +48,9 @@ function bold(text) {
|
|
|
42
48
|
* @returns The dim string
|
|
43
49
|
*/
|
|
44
50
|
function dim(text) {
|
|
51
|
+
if (typeof supportsColor === 'function' ? !supportsColor() : false) {
|
|
52
|
+
return text;
|
|
53
|
+
}
|
|
45
54
|
return `${constants_1.COLORS.dim}${text}${constants_1.COLORS.reset}`;
|
|
46
55
|
}
|
|
47
56
|
/**
|
|
@@ -51,6 +60,9 @@ function dim(text) {
|
|
|
51
60
|
* @returns The underlined string
|
|
52
61
|
*/
|
|
53
62
|
function underline(text) {
|
|
63
|
+
if (typeof supportsColor === 'function' ? !supportsColor() : false) {
|
|
64
|
+
return text;
|
|
65
|
+
}
|
|
54
66
|
return `${constants_1.COLORS.underscore}${text}${constants_1.COLORS.reset}`;
|
|
55
67
|
}
|
|
56
68
|
/**
|
package/dist/utils/colors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/utils/colors.ts"],"names":[],"mappings":";;AAaA,
|
|
1
|
+
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/utils/colors.ts"],"names":[],"mappings":";;AAaA,4BAKC;AAQD,oBAKC;AAQD,kBAKC;AAQD,8BAKC;AAQD,kBAEC;AAQD,sBAEC;AAQD,wBAEC;AAQD,oBAEC;AAQD,0BAEC;AAQD,oBAEC;AAQD,oBAEC;AAOD,sCA8BC;AApKD,iDAA2C;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I,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* String utility functions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Center a string with padding
|
|
6
|
+
*
|
|
7
|
+
* @param str - The string to center
|
|
8
|
+
* @param length - The total length of the returned string
|
|
9
|
+
* @param char - The character to use for padding (default: space)
|
|
10
|
+
* @returns The padded string
|
|
11
|
+
*/
|
|
12
|
+
export declare function padCenter(str: string, length: number, char?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Truncate a string to a specified length and add ellipsis if needed
|
|
15
|
+
*
|
|
16
|
+
* @param str - The string to truncate
|
|
17
|
+
* @param maxLength - The maximum length allowed
|
|
18
|
+
* @returns The truncated string
|
|
19
|
+
*/
|
|
20
|
+
export declare function truncate(str: string, maxLength: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* Ensure that the string is at least a certain length
|
|
23
|
+
*
|
|
24
|
+
* @param str - The string to pad
|
|
25
|
+
* @param length - The minimum length desired
|
|
26
|
+
* @param char - The character to use for padding (default: space)
|
|
27
|
+
* @returns The padded string
|
|
28
|
+
*/
|
|
29
|
+
export declare function padEnd(str: string, length: number, char?: string): string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* String utility functions
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.padCenter = padCenter;
|
|
7
|
+
exports.truncate = truncate;
|
|
8
|
+
exports.padEnd = padEnd;
|
|
9
|
+
/**
|
|
10
|
+
* Center a string with padding
|
|
11
|
+
*
|
|
12
|
+
* @param str - The string to center
|
|
13
|
+
* @param length - The total length of the returned string
|
|
14
|
+
* @param char - The character to use for padding (default: space)
|
|
15
|
+
* @returns The padded string
|
|
16
|
+
*/
|
|
17
|
+
function padCenter(str, length, char = ' ') {
|
|
18
|
+
if (str.length >= length)
|
|
19
|
+
return str;
|
|
20
|
+
const leftPadding = Math.floor((length - str.length) / 2);
|
|
21
|
+
const rightPadding = length - str.length - leftPadding;
|
|
22
|
+
return char.repeat(leftPadding) + str + char.repeat(rightPadding);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Truncate a string to a specified length and add ellipsis if needed
|
|
26
|
+
*
|
|
27
|
+
* @param str - The string to truncate
|
|
28
|
+
* @param maxLength - The maximum length allowed
|
|
29
|
+
* @returns The truncated string
|
|
30
|
+
*/
|
|
31
|
+
function truncate(str, maxLength) {
|
|
32
|
+
if (str.length <= maxLength)
|
|
33
|
+
return str;
|
|
34
|
+
const ellipsis = '...';
|
|
35
|
+
return str.substring(0, maxLength - ellipsis.length) + ellipsis;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Ensure that the string is at least a certain length
|
|
39
|
+
*
|
|
40
|
+
* @param str - The string to pad
|
|
41
|
+
* @param length - The minimum length desired
|
|
42
|
+
* @param char - The character to use for padding (default: space)
|
|
43
|
+
* @returns The padded string
|
|
44
|
+
*/
|
|
45
|
+
function padEnd(str, length, char = ' ') {
|
|
46
|
+
if (str.length >= length)
|
|
47
|
+
return str;
|
|
48
|
+
return str + char.repeat(length - str.length);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/utils/string.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAUH,8BAOC;AASD,4BAKC;AAUD,wBAIC;AA3CD;;;;;;;GAOG;AACH,SAAgB,SAAS,CAAC,GAAW,EAAE,MAAc,EAAE,OAAe,GAAG;IACvE,IAAI,GAAG,CAAC,MAAM,IAAI,MAAM;QAAE,OAAO,GAAG,CAAC;IAErC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,MAAM,YAAY,GAAG,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC;IAEvD,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,SAAiB;IACrD,IAAI,GAAG,CAAC,MAAM,IAAI,SAAS;QAAE,OAAO,GAAG,CAAC;IAExC,MAAM,QAAQ,GAAG,KAAK,CAAC;IACvB,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;AAClE,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,MAAM,CAAC,GAAW,EAAE,MAAc,EAAE,OAAe,GAAG;IACpE,IAAI,GAAG,CAAC,MAAM,IAAI,MAAM;QAAE,OAAO,GAAG,CAAC;IAErC,OAAO,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "traceperf",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "High-performance function execution tracking and monitoring for Node.js",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -34,14 +34,17 @@
|
|
|
34
34
|
"dev": "tsc --watch"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [
|
|
37
|
-
"logging",
|
|
38
37
|
"performance",
|
|
39
|
-
"debugging",
|
|
40
|
-
"console",
|
|
41
|
-
"trace",
|
|
42
38
|
"profiling",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
39
|
+
"monitoring",
|
|
40
|
+
"tracking",
|
|
41
|
+
"execution",
|
|
42
|
+
"function-tracing",
|
|
43
|
+
"memory-tracking",
|
|
44
|
+
"bottleneck-detection",
|
|
45
|
+
"sampling",
|
|
46
|
+
"debug",
|
|
47
|
+
"optimization"
|
|
45
48
|
],
|
|
46
49
|
"author": "Shubh Wadekar",
|
|
47
50
|
"license": "MIT",
|