@discomedia/utils 1.0.10 → 1.0.11
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/dist/index.cjs +123 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +123 -0
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/performance-timer.d.ts +73 -0
- package/dist/types/performance-timer.d.ts.map +1 -0
- package/dist/types-frontend/index.d.ts +2 -0
- package/dist/types-frontend/index.d.ts.map +1 -1
- package/dist/types-frontend/performance-timer.d.ts +73 -0
- package/dist/types-frontend/performance-timer.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import * as misc from './misc-utils';
|
|
|
5
5
|
import * as polygon from './polygon';
|
|
6
6
|
import * as llm from './llm-openai';
|
|
7
7
|
import * as llmImages from './llm-images';
|
|
8
|
+
import { PerformanceTimer } from './performance-timer';
|
|
8
9
|
import * as ta from './technical-analysis';
|
|
9
10
|
export * from './types';
|
|
10
11
|
export { AlpacaTradingAPI } from './alpaca-trading-api';
|
|
@@ -121,6 +122,7 @@ export declare const disco: {
|
|
|
121
122
|
logIfDebug: (message: string, data?: unknown, type?: "info" | "warn" | "error" | "debug" | "trace") => void;
|
|
122
123
|
fetchWithRetry: typeof misc.fetchWithRetry;
|
|
123
124
|
validatePolygonApiKey: typeof misc.validatePolygonApiKey;
|
|
125
|
+
Timer: typeof PerformanceTimer;
|
|
124
126
|
};
|
|
125
127
|
};
|
|
126
128
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,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CAAC;gBAAkB,CAAC;;;;;eAAjgX,CAAC;;;iBAAiE,CAAC;;kBAAmC,CAAC;;;;;kBAA65Q,CAAC;oBAAsB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAD9zZ,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A class to measure performance of code execution.
|
|
3
|
+
*
|
|
4
|
+
* This utility records elapsed time during execution and provides a detailed
|
|
5
|
+
* breakdown of elapsed time between checkpoints.
|
|
6
|
+
*
|
|
7
|
+
* Usage example:
|
|
8
|
+
* const timer = new PerformanceTimer();
|
|
9
|
+
* timer.checkpoint('Start Processing');
|
|
10
|
+
* // ... code for processing
|
|
11
|
+
* timer.checkpoint('After Task 1');
|
|
12
|
+
* // ... additional processing code
|
|
13
|
+
* timer.stop();
|
|
14
|
+
* console.log(timer.generateReport());
|
|
15
|
+
*
|
|
16
|
+
* Methods:
|
|
17
|
+
* - checkpoint(label: string): Record a timestamped checkpoint.
|
|
18
|
+
* - stop(): Stop the timer and compute the total elapsed time.
|
|
19
|
+
* - generateReport(): Return a performance report with total time and phases.
|
|
20
|
+
* - formatPerformanceReport(): Return a formatted string of the performance report.
|
|
21
|
+
* - getElapsedSeconds(): Get the current elapsed time in seconds.
|
|
22
|
+
*/
|
|
23
|
+
export declare class PerformanceTimer {
|
|
24
|
+
private startTime;
|
|
25
|
+
private checkpoints;
|
|
26
|
+
private totalTime;
|
|
27
|
+
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Gets the current elapsed time in seconds.
|
|
30
|
+
*
|
|
31
|
+
* @returns The elapsed time in seconds with 3 decimal places of precision.
|
|
32
|
+
*/
|
|
33
|
+
getElapsedSeconds(): number;
|
|
34
|
+
/**
|
|
35
|
+
* Records a checkpoint with the given label.
|
|
36
|
+
*
|
|
37
|
+
* @param label - A descriptive label for the checkpoint.
|
|
38
|
+
*/
|
|
39
|
+
checkpoint(label: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Stops the timer and sets the total elapsed time.
|
|
42
|
+
*/
|
|
43
|
+
stop(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Generates a performance report containing the total elapsed time and
|
|
46
|
+
* breakdown of phases between checkpoints.
|
|
47
|
+
*
|
|
48
|
+
* @returns A performance report object.
|
|
49
|
+
* @throws Error if the timer is not stopped before generating the report.
|
|
50
|
+
*/
|
|
51
|
+
analyseReportData(): PerformanceReport;
|
|
52
|
+
/**
|
|
53
|
+
* Returns a formatted string of the performance report.
|
|
54
|
+
*
|
|
55
|
+
* @returns A string detailing the total execution time and phase breakdown.
|
|
56
|
+
*/
|
|
57
|
+
generateReport(): string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Interface representing a single phase of performance measurement.
|
|
61
|
+
*/
|
|
62
|
+
export interface PerformancePhase {
|
|
63
|
+
label: string;
|
|
64
|
+
duration: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Interface representing the full performance report.
|
|
68
|
+
*/
|
|
69
|
+
export interface PerformanceReport {
|
|
70
|
+
totalTime: number;
|
|
71
|
+
phases: PerformancePhase[];
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=performance-timer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance-timer.d.ts","sourceRoot":"","sources":["../../src/performance-timer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,SAAS,CAAgB;;IAQjC;;;;OAIG;IACH,iBAAiB,IAAI,MAAM;IAK3B;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,IAAI,IAAI,IAAI;IAIZ;;;;;;OAMG;IACH,iBAAiB,IAAI,iBAAiB;IAuCtC;;;;OAIG;IACI,cAAc,IAAI,MAAM;CA4BhC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B"}
|
|
@@ -5,6 +5,7 @@ import * as misc from './misc-utils';
|
|
|
5
5
|
import * as polygon from './polygon';
|
|
6
6
|
import * as llm from './llm-openai';
|
|
7
7
|
import * as llmImages from './llm-images';
|
|
8
|
+
import { PerformanceTimer } from './performance-timer';
|
|
8
9
|
import * as ta from './technical-analysis';
|
|
9
10
|
export * from './types';
|
|
10
11
|
export { AlpacaTradingAPI } from './alpaca-trading-api';
|
|
@@ -121,6 +122,7 @@ export declare const disco: {
|
|
|
121
122
|
logIfDebug: (message: string, data?: unknown, type?: "info" | "warn" | "error" | "debug" | "trace") => void;
|
|
122
123
|
fetchWithRetry: typeof misc.fetchWithRetry;
|
|
123
124
|
validatePolygonApiKey: typeof misc.validatePolygonApiKey;
|
|
125
|
+
Timer: typeof PerformanceTimer;
|
|
124
126
|
};
|
|
125
127
|
};
|
|
126
128
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceR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elapsed time during execution and provides a detailed
|
|
5
|
+
* breakdown of elapsed time between checkpoints.
|
|
6
|
+
*
|
|
7
|
+
* Usage example:
|
|
8
|
+
* const timer = new PerformanceTimer();
|
|
9
|
+
* timer.checkpoint('Start Processing');
|
|
10
|
+
* // ... code for processing
|
|
11
|
+
* timer.checkpoint('After Task 1');
|
|
12
|
+
* // ... additional processing code
|
|
13
|
+
* timer.stop();
|
|
14
|
+
* console.log(timer.generateReport());
|
|
15
|
+
*
|
|
16
|
+
* Methods:
|
|
17
|
+
* - checkpoint(label: string): Record a timestamped checkpoint.
|
|
18
|
+
* - stop(): Stop the timer and compute the total elapsed time.
|
|
19
|
+
* - generateReport(): Return a performance report with total time and phases.
|
|
20
|
+
* - formatPerformanceReport(): Return a formatted string of the performance report.
|
|
21
|
+
* - getElapsedSeconds(): Get the current elapsed time in seconds.
|
|
22
|
+
*/
|
|
23
|
+
export declare class PerformanceTimer {
|
|
24
|
+
private startTime;
|
|
25
|
+
private checkpoints;
|
|
26
|
+
private totalTime;
|
|
27
|
+
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Gets the current elapsed time in seconds.
|
|
30
|
+
*
|
|
31
|
+
* @returns The elapsed time in seconds with 3 decimal places of precision.
|
|
32
|
+
*/
|
|
33
|
+
getElapsedSeconds(): number;
|
|
34
|
+
/**
|
|
35
|
+
* Records a checkpoint with the given label.
|
|
36
|
+
*
|
|
37
|
+
* @param label - A descriptive label for the checkpoint.
|
|
38
|
+
*/
|
|
39
|
+
checkpoint(label: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Stops the timer and sets the total elapsed time.
|
|
42
|
+
*/
|
|
43
|
+
stop(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Generates a performance report containing the total elapsed time and
|
|
46
|
+
* breakdown of phases between checkpoints.
|
|
47
|
+
*
|
|
48
|
+
* @returns A performance report object.
|
|
49
|
+
* @throws Error if the timer is not stopped before generating the report.
|
|
50
|
+
*/
|
|
51
|
+
analyseReportData(): PerformanceReport;
|
|
52
|
+
/**
|
|
53
|
+
* Returns a formatted string of the performance report.
|
|
54
|
+
*
|
|
55
|
+
* @returns A string detailing the total execution time and phase breakdown.
|
|
56
|
+
*/
|
|
57
|
+
generateReport(): string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Interface representing a single phase of performance measurement.
|
|
61
|
+
*/
|
|
62
|
+
export interface PerformancePhase {
|
|
63
|
+
label: string;
|
|
64
|
+
duration: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Interface representing the full performance report.
|
|
68
|
+
*/
|
|
69
|
+
export interface PerformanceReport {
|
|
70
|
+
totalTime: number;
|
|
71
|
+
phases: PerformancePhase[];
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=performance-timer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance-timer.d.ts","sourceRoot":"","sources":["../../src/performance-timer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,SAAS,CAAgB;;IAQjC;;;;OAIG;IACH,iBAAiB,IAAI,MAAM;IAK3B;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,IAAI,IAAI,IAAI;IAIZ;;;;;;OAMG;IACH,iBAAiB,IAAI,iBAAiB;IAuCtC;;;;OAIG;IACI,cAAc,IAAI,MAAM;CA4BhC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B"}
|