@contrail/util 1.1.15-alpha-13 → 1.1.15-alpha-15
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.
|
@@ -27,7 +27,7 @@ export declare function withTimingAsync<T>(label: string, fn: () => Promise<T>,
|
|
|
27
27
|
export declare function withTimingSync<T>(label: string, fn: () => T, options?: {
|
|
28
28
|
parentNodeId?: string | null;
|
|
29
29
|
}): T;
|
|
30
|
-
export declare function displayTimingTree(nodes?: TimingSpans, depth?: number): string;
|
|
30
|
+
export declare function displayTimingTree(nodes?: TimingSpans, depth?: number, prefix?: string): string;
|
|
31
31
|
export declare function startSpan(spanName: string, options?: {
|
|
32
32
|
parentNodeId?: string | null;
|
|
33
33
|
}): void;
|
|
@@ -119,9 +119,8 @@ function withTimingSync(label, fn, options) {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
function displayTimingTree(nodes = DEFAULT_TIMING_PROFILE.timingSpans, depth = 0) {
|
|
122
|
+
function displayTimingTree(nodes = DEFAULT_TIMING_PROFILE.timingSpans, depth = 0, prefix = '') {
|
|
123
123
|
const lines = [];
|
|
124
|
-
const indent = ' '.repeat(depth);
|
|
125
124
|
const totalWidth = 120;
|
|
126
125
|
const timeWidth = 10;
|
|
127
126
|
const sortedNodes = [...nodes].sort((a, b) => a.startTime - b.startTime);
|
|
@@ -150,30 +149,38 @@ function displayTimingTree(nodes = DEFAULT_TIMING_PROFILE.timingSpans, depth = 0
|
|
|
150
149
|
if (currentGroup.length > 0) {
|
|
151
150
|
groups.push(currentGroup);
|
|
152
151
|
}
|
|
153
|
-
groups.forEach((group) => {
|
|
152
|
+
groups.forEach((group, groupIndex) => {
|
|
153
|
+
const isLastGroup = groupIndex === groups.length - 1;
|
|
154
154
|
if (group.length === 1) {
|
|
155
155
|
const node = group[0];
|
|
156
156
|
const timeStr = `${node.durationMs.toFixed(2)}ms`;
|
|
157
|
-
const
|
|
158
|
-
const
|
|
157
|
+
const connector = depth === 0 ? '' : isLastGroup ? '└── ' : '├── ';
|
|
158
|
+
const labelWithPrefix = `${prefix}${connector}${node.label}`;
|
|
159
|
+
const availableWidth = totalWidth - timeWidth - labelWithPrefix.length;
|
|
159
160
|
const dots = '.'.repeat(Math.max(2, availableWidth));
|
|
160
|
-
lines.push(`${
|
|
161
|
+
lines.push(`${labelWithPrefix}${dots}${timeStr.padStart(timeWidth)}`);
|
|
161
162
|
if (node.children && node.children.length > 0) {
|
|
162
|
-
|
|
163
|
+
const childPrefix = prefix + (depth === 0 ? '' : isLastGroup ? ' ' : '│ ');
|
|
164
|
+
lines.push(displayTimingTree(node.children, depth + 1, childPrefix));
|
|
163
165
|
}
|
|
164
166
|
}
|
|
165
167
|
else {
|
|
166
|
-
const
|
|
168
|
+
const connector = depth === 0 ? '' : isLastGroup ? '└── ' : '├── ';
|
|
169
|
+
const parallelHeader = `${prefix}${connector}∥ Parallel Operations (${group.length})`;
|
|
167
170
|
lines.push(parallelHeader);
|
|
168
|
-
group.forEach((node) => {
|
|
171
|
+
group.forEach((node, nodeIndex) => {
|
|
172
|
+
const isLastNode = nodeIndex === group.length - 1;
|
|
169
173
|
const timeStr = `${node.durationMs.toFixed(2)}ms`;
|
|
170
174
|
const parallelIndicator = '∥ ';
|
|
171
|
-
const
|
|
172
|
-
const
|
|
175
|
+
const nodeConnector = isLastNode ? '└── ' : '├── ';
|
|
176
|
+
const nodePrefix = prefix + (depth === 0 ? '' : isLastGroup ? ' ' : '│ ');
|
|
177
|
+
const labelWithPrefix = `${nodePrefix}${nodeConnector}${parallelIndicator}${node.label}`;
|
|
178
|
+
const availableWidth = totalWidth - timeWidth - labelWithPrefix.length;
|
|
173
179
|
const dots = '.'.repeat(Math.max(2, availableWidth));
|
|
174
|
-
lines.push(`${
|
|
180
|
+
lines.push(`${labelWithPrefix}${dots}${timeStr.padStart(timeWidth)}`);
|
|
175
181
|
if (node.children && node.children.length > 0) {
|
|
176
|
-
|
|
182
|
+
const childPrefix = nodePrefix + (isLastNode ? ' ' : '│ ');
|
|
183
|
+
lines.push(displayTimingTree(node.children, depth + 1, childPrefix));
|
|
177
184
|
}
|
|
178
185
|
});
|
|
179
186
|
}
|