@contrail/util 1.1.15-alpha-11 → 1.1.15-alpha-12
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.
|
@@ -2,7 +2,7 @@ type TimingSpans = TimingNode[];
|
|
|
2
2
|
type TimingStack = TimingNode[];
|
|
3
3
|
export type TimingNode = {
|
|
4
4
|
label: string;
|
|
5
|
-
id:
|
|
5
|
+
id: string;
|
|
6
6
|
durationMs: number;
|
|
7
7
|
children: TimingNode[];
|
|
8
8
|
startTime: number;
|
|
@@ -14,22 +14,22 @@ type ActiveSpan = {
|
|
|
14
14
|
};
|
|
15
15
|
type TimingProfile = {
|
|
16
16
|
activeSpans: Map<string, ActiveSpan>;
|
|
17
|
-
spansById: Map<
|
|
17
|
+
spansById: Map<string, TimingNode>;
|
|
18
18
|
timingSpans: TimingSpans;
|
|
19
19
|
timingStack: TimingStack;
|
|
20
20
|
};
|
|
21
21
|
export declare function getDefaultTimingProfile(): TimingProfile;
|
|
22
22
|
export declare function clearDefaultTimingProfile(): void;
|
|
23
|
-
export declare function getCurrentParentNodeId():
|
|
23
|
+
export declare function getCurrentParentNodeId(): string | null;
|
|
24
24
|
export declare function withTimingAsync<T>(label: string, fn: () => Promise<T>, options?: {
|
|
25
|
-
parentNodeId?:
|
|
25
|
+
parentNodeId?: string | null;
|
|
26
26
|
}): Promise<T>;
|
|
27
27
|
export declare function withTimingSync<T>(label: string, fn: () => T, options?: {
|
|
28
|
-
parentNodeId?:
|
|
28
|
+
parentNodeId?: string | null;
|
|
29
29
|
}): T;
|
|
30
30
|
export declare function displayTimingTree(nodes?: TimingSpans, depth?: number): string;
|
|
31
31
|
export declare function startSpan(spanName: string, options?: {
|
|
32
|
-
parentNodeId?:
|
|
32
|
+
parentNodeId?: string | null;
|
|
33
33
|
}): void;
|
|
34
34
|
export declare function endSpan(spanName: string): void;
|
|
35
35
|
export {};
|
|
@@ -56,7 +56,7 @@ function withTimingAsync(label, fn, options) {
|
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
57
|
const start = performance.now();
|
|
58
58
|
const chosenId = options === null || options === void 0 ? void 0 : options.parentNodeId;
|
|
59
|
-
const uniqueId =
|
|
59
|
+
const uniqueId = generateUUID();
|
|
60
60
|
const timingNode = {
|
|
61
61
|
label,
|
|
62
62
|
durationMs: 0,
|
|
@@ -88,7 +88,7 @@ function withTimingAsync(label, fn, options) {
|
|
|
88
88
|
function withTimingSync(label, fn, options) {
|
|
89
89
|
const start = performance.now();
|
|
90
90
|
const chosenId = options === null || options === void 0 ? void 0 : options.parentNodeId;
|
|
91
|
-
const uniqueId =
|
|
91
|
+
const uniqueId = generateUUID();
|
|
92
92
|
const timingNode = {
|
|
93
93
|
label,
|
|
94
94
|
durationMs: 0,
|
|
@@ -193,7 +193,7 @@ function startSpan(spanName, options) {
|
|
|
193
193
|
}
|
|
194
194
|
const startTime = performance.now();
|
|
195
195
|
const chosenId = options === null || options === void 0 ? void 0 : options.parentNodeId;
|
|
196
|
-
const uniqueId =
|
|
196
|
+
const uniqueId = generateUUID();
|
|
197
197
|
const timingNode = {
|
|
198
198
|
label: spanName,
|
|
199
199
|
durationMs: 0,
|
|
@@ -241,3 +241,10 @@ function endSpan(spanName) {
|
|
|
241
241
|
}
|
|
242
242
|
DEFAULT_TIMING_PROFILE.activeSpans.delete(spanName);
|
|
243
243
|
}
|
|
244
|
+
function generateUUID() {
|
|
245
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
246
|
+
const r = (Math.random() * 16) | 0;
|
|
247
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
248
|
+
return v.toString(16);
|
|
249
|
+
});
|
|
250
|
+
}
|