@quiesco/core 0.11.0 → 0.12.1
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/config.d.ts +10 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/devices/ios.d.ts +4 -1
- package/dist/devices/ios.d.ts.map +1 -1
- package/dist/devices/ios.js +56 -17
- package/dist/devices/ios.js.map +1 -1
- package/dist/session.d.ts +0 -2
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +13 -2
- package/dist/session.js.map +1 -1
- package/dist/timeline.d.ts +8 -0
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js +23 -4
- package/dist/timeline.js.map +1 -1
- package/package.json +2 -2
- package/src/config.ts +11 -3
- package/src/devices/ios.ts +53 -16
- package/src/session.ts +14 -1
- package/src/timeline.ts +30 -4
package/src/timeline.ts
CHANGED
|
@@ -16,6 +16,10 @@ export interface TimelineEntry {
|
|
|
16
16
|
end: number;
|
|
17
17
|
/** Of which waiting for idle in the agent. */
|
|
18
18
|
syncMs?: number;
|
|
19
|
+
/** What the waits for idle ended on, per tracker (issue #93). */
|
|
20
|
+
syncBusy?: string[];
|
|
21
|
+
/** Native calls pending when the call returned, not counted: the `native-module` tracker is off (issue #94). */
|
|
22
|
+
nativeCallsNotCounted?: string[];
|
|
19
23
|
/** The steps of a multi-step action, `atMs` from `start` (issue #78). */
|
|
20
24
|
steps?: StepTiming[];
|
|
21
25
|
error?: string;
|
|
@@ -24,9 +28,14 @@ export interface TimelineEntry {
|
|
|
24
28
|
/** What a call's result (or error data) says about its timing. */
|
|
25
29
|
export interface CallTiming {
|
|
26
30
|
syncMs?: number;
|
|
31
|
+
syncBusy?: string[];
|
|
32
|
+
nativeCallsNotCounted?: string[];
|
|
27
33
|
steps?: StepTiming[];
|
|
28
34
|
}
|
|
29
35
|
|
|
36
|
+
/** Said with the native calls an action did not wait for (issue #94). */
|
|
37
|
+
export const NOT_COUNTED_NOTE = 'pending when the call returned, not waited for: the native-module tracker is off';
|
|
38
|
+
|
|
30
39
|
/** What a call still running when the timeline is written says (issue #84). */
|
|
31
40
|
export const STILL_RUNNING = 'still running when the scenario ended (the test ended it first: its timeout?)';
|
|
32
41
|
|
|
@@ -66,7 +75,16 @@ export class Timeline {
|
|
|
66
75
|
try {
|
|
67
76
|
const r = await fn();
|
|
68
77
|
const t = timing?.(r);
|
|
69
|
-
add({
|
|
78
|
+
add({
|
|
79
|
+
method,
|
|
80
|
+
label,
|
|
81
|
+
start,
|
|
82
|
+
end: Date.now(),
|
|
83
|
+
...(t?.syncMs !== undefined ? { syncMs: t.syncMs } : {}),
|
|
84
|
+
...(t?.syncBusy !== undefined && t.syncBusy.length > 0 ? { syncBusy: t.syncBusy } : {}),
|
|
85
|
+
...(t?.nativeCallsNotCounted !== undefined && t.nativeCallsNotCounted.length > 0 ? { nativeCallsNotCounted: t.nativeCallsNotCounted } : {}),
|
|
86
|
+
...(t?.steps !== undefined && t.steps.length > 0 ? { steps: t.steps } : {}),
|
|
87
|
+
});
|
|
70
88
|
return r;
|
|
71
89
|
} catch (e) {
|
|
72
90
|
// A multi-step action that failed still reports its steps (issue #78).
|
|
@@ -95,7 +113,9 @@ export class Timeline {
|
|
|
95
113
|
const us = (t: number): number => Math.round((t - this.started) * 1000);
|
|
96
114
|
const events: Record<string, unknown>[] = [{ name: 'process_name', ph: 'M', pid: 1, tid: 1, args: { name: `Quiesco: ${this.name}` } }];
|
|
97
115
|
for (const e of this.all) {
|
|
98
|
-
|
|
116
|
+
const args = { ...(e.error !== undefined ? { error: e.error } : {}), ...(e.nativeCallsNotCounted !== undefined ? { nativeCallsNotCounted: e.nativeCallsNotCounted, note: NOT_COUNTED_NOTE } : {}) };
|
|
117
|
+
events.push({ name: `${e.method} ${e.label}`.trim(), cat: e.method, ph: 'X', ts: us(e.start), dur: Math.max(1, us(e.end) - us(e.start)), pid: 1, tid: 1, args });
|
|
118
|
+
const busy = e.syncBusy !== undefined ? { busy: e.syncBusy } : {};
|
|
99
119
|
if (e.steps !== undefined) {
|
|
100
120
|
e.steps.forEach((s, i) => {
|
|
101
121
|
const ts = us(e.start + s.atMs);
|
|
@@ -103,7 +123,7 @@ export class Timeline {
|
|
|
103
123
|
if (s.syncMs > 0) events.push({ name: 'wait for idle', cat: 'sync', ph: 'X', ts: ts + Math.max(0, s.ms - s.syncMs) * 1000, dur: Math.max(1, s.syncMs * 1000), pid: 1, tid: 1 });
|
|
104
124
|
});
|
|
105
125
|
} else if (e.syncMs !== undefined && e.syncMs > 0) {
|
|
106
|
-
events.push({ name: 'wait for idle', cat: 'sync', ph: 'X', ts: us(e.start), dur: Math.max(1, Math.round(e.syncMs * 1000)), pid: 1, tid: 1 });
|
|
126
|
+
events.push({ name: 'wait for idle', cat: 'sync', ph: 'X', ts: us(e.start), dur: Math.max(1, Math.round(e.syncMs * 1000)), pid: 1, tid: 1, args: busy });
|
|
107
127
|
}
|
|
108
128
|
}
|
|
109
129
|
return JSON.stringify({ traceEvents: events, displayTimeUnit: 'ms' });
|
|
@@ -120,6 +140,11 @@ export class Timeline {
|
|
|
120
140
|
const sync = e.syncMs !== undefined ? Math.min(100, (e.syncMs / Math.max(1, e.end - e.start)) * 100) : 0;
|
|
121
141
|
const cls = e.error !== undefined ? 'row failed' : 'row';
|
|
122
142
|
const err = e.error !== undefined ? `<div class="err">${esc(e.error)}</div>` : '';
|
|
143
|
+
const notes = [
|
|
144
|
+
...(e.syncBusy !== undefined ? [`idle wait ended on: ${e.syncBusy.join(' | ')}`] : []),
|
|
145
|
+
...(e.nativeCallsNotCounted !== undefined ? [`native calls ${NOT_COUNTED_NOTE}: ${e.nativeCallsNotCounted.join(', ')}`] : []),
|
|
146
|
+
];
|
|
147
|
+
const why = notes.length > 0 ? `<div class="why">${notes.map(esc).join('<br>')}</div>` : '';
|
|
123
148
|
const steps = (e.steps ?? [])
|
|
124
149
|
.map((s, i) => {
|
|
125
150
|
const sLeft = ((e.start + s.atMs - this.started) / total) * 100;
|
|
@@ -128,7 +153,7 @@ export class Timeline {
|
|
|
128
153
|
return `<div class="row step"><div class="name">step ${i + 1} ${esc(s.label)}</div><div class="ms">${s.ms} ms (idle wait ${s.syncMs} ms)</div><div class="track"><div class="bar" style="left:${sLeft.toFixed(2)}%;width:${sWidth.toFixed(2)}%"><div class="sync" style="width:${sSync.toFixed(1)}%"></div></div></div></div>`;
|
|
129
154
|
})
|
|
130
155
|
.join('');
|
|
131
|
-
return `<div class="${cls}"><div class="name">${esc(`${e.method} ${e.label}`)}</div><div class="ms">${e.end - e.start} ms${e.syncMs !== undefined ? ` (idle wait ${Math.round(e.syncMs)} ms)` : ''}</div><div class="track"><div class="bar" style="left:${left.toFixed(2)}%;width:${width.toFixed(2)}%"><div class="sync" style="width:${sync.toFixed(1)}%"></div></div></div>${err}</div>${steps}`;
|
|
156
|
+
return `<div class="${cls}"><div class="name">${esc(`${e.method} ${e.label}`)}</div><div class="ms">${e.end - e.start} ms${e.syncMs !== undefined ? ` (idle wait ${Math.round(e.syncMs)} ms)` : ''}</div><div class="track"><div class="bar" style="left:${left.toFixed(2)}%;width:${width.toFixed(2)}%"><div class="sync" style="width:${sync.toFixed(1)}%"></div></div></div>${why}${err}</div>${steps}`;
|
|
132
157
|
})
|
|
133
158
|
.join('\n');
|
|
134
159
|
return `<!doctype html><html><head><meta charset="utf-8"><title>${esc(this.name)} — Quiesco timeline</title><style>
|
|
@@ -137,6 +162,7 @@ body{font:13px system-ui,sans-serif;margin:16px;color:#222}h1{font-size:16px}
|
|
|
137
162
|
.name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,monospace}.ms{color:#666;text-align:right}
|
|
138
163
|
.track{position:relative;height:12px;background:#f4f4f4}.bar{position:absolute;top:0;height:12px;background:#6b8de3}.sync{height:12px;background:#b9c9f3}
|
|
139
164
|
.step .name{padding-left:16px;color:#555}.step .bar{background:#9aa9cc}
|
|
165
|
+
.why{grid-column:1/-1;color:#666;white-space:pre-wrap;font-family:ui-monospace,monospace;font-size:12px;padding:0 0 4px 16px}
|
|
140
166
|
.failed .bar{background:#d9534f}.failed .name{color:#c00}.err{grid-column:1/-1;color:#c00;white-space:pre-wrap;font-family:ui-monospace,monospace;font-size:12px;padding:4px 0 6px}
|
|
141
167
|
</style></head><body><h1>${esc(this.name)}</h1><p>${entries.length} calls, ${total} ms. Light part of a bar: waiting for the app to be idle.</p>
|
|
142
168
|
${rows}
|