@prismatic-io/spectral 10.3.12 → 10.3.13
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.
|
@@ -4,6 +4,7 @@ exports.createDebugContext = createDebugContext;
|
|
|
4
4
|
exports.logDebugResults = logDebugResults;
|
|
5
5
|
const node_process_1 = require("node:process");
|
|
6
6
|
const node_perf_hooks_1 = require("node:perf_hooks");
|
|
7
|
+
const MEMORY_USAGE_CONVERSION = 1024 * 1024;
|
|
7
8
|
function createDebugContext(context) {
|
|
8
9
|
const globalDebug = Boolean(context.globalDebug);
|
|
9
10
|
return {
|
|
@@ -26,11 +27,13 @@ function createDebugContext(context) {
|
|
|
26
27
|
},
|
|
27
28
|
memoryUsage: (actionContext, label, showDetail) => {
|
|
28
29
|
if (globalDebug) {
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
const usage = showDetail
|
|
31
|
+
? memoryUsageInMB()
|
|
32
|
+
: // @ts-expect-error: memoryUsage.rss() is documented but not typed
|
|
33
|
+
node_process_1.memoryUsage.rss() / MEMORY_USAGE_CONVERSION;
|
|
31
34
|
actionContext.debug.results.memoryUsage.push({
|
|
32
35
|
mark: label,
|
|
33
|
-
rss: typeof usage === "number" ? usage
|
|
36
|
+
rss: typeof usage === "number" ? usage : usage.rss,
|
|
34
37
|
detail: typeof usage === "number" ? undefined : usage,
|
|
35
38
|
});
|
|
36
39
|
}
|
|
@@ -47,3 +50,16 @@ function logDebugResults(context) {
|
|
|
47
50
|
context.logger.metric(context.debug.results);
|
|
48
51
|
}
|
|
49
52
|
}
|
|
53
|
+
function memoryUsageInMB() {
|
|
54
|
+
const usage = (0, node_process_1.memoryUsage)();
|
|
55
|
+
return Object.keys(usage).reduce((accum, key) => {
|
|
56
|
+
accum[key] = usage[key] / MEMORY_USAGE_CONVERSION;
|
|
57
|
+
return accum;
|
|
58
|
+
}, {
|
|
59
|
+
rss: -1,
|
|
60
|
+
heapTotal: -1,
|
|
61
|
+
heapUsed: -1,
|
|
62
|
+
external: -1,
|
|
63
|
+
arrayBuffers: -1,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -49,15 +49,16 @@ interface DebugResult {
|
|
|
49
49
|
memoryUsage: Array<{
|
|
50
50
|
mark: string;
|
|
51
51
|
rss: number;
|
|
52
|
-
detail?:
|
|
53
|
-
rss: number;
|
|
54
|
-
heapTotal: number;
|
|
55
|
-
heapUsed: number;
|
|
56
|
-
external: number;
|
|
57
|
-
arrayBuffers: number;
|
|
58
|
-
};
|
|
52
|
+
detail?: MemoryUsage;
|
|
59
53
|
}>;
|
|
60
54
|
}
|
|
55
|
+
export interface MemoryUsage {
|
|
56
|
+
rss: number;
|
|
57
|
+
heapTotal: number;
|
|
58
|
+
heapUsed: number;
|
|
59
|
+
external: number;
|
|
60
|
+
arrayBuffers: number;
|
|
61
|
+
}
|
|
61
62
|
export type ExecutionFrame = ({
|
|
62
63
|
invokedByExecutionJWT: string;
|
|
63
64
|
invokedByExecutionStartedAt: string;
|
package/package.json
CHANGED