@hydranium/protocol 1.0.0-next.360 → 1.0.0-next.361
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/lib/client/worker-handshake.d.ts +5 -1
- package/lib/client/worker-handshake.d.ts.map +1 -1
- package/lib/client/worker-handshake.js.map +1 -1
- package/lib/profile-session.d.ts +12 -10
- package/lib/profile-session.d.ts.map +1 -1
- package/lib/profile-session.js +10 -10
- package/lib/profile-session.js.map +1 -1
- package/package.json +1 -1
- package/src/client/worker-handshake.ts +5 -1
- package/src/profile-session.ts +18 -13
|
@@ -81,7 +81,11 @@ export declare const WORKER_BOOTSTRAP_PHASE = "bootstrap";
|
|
|
81
81
|
export interface WorkerErrorMessage {
|
|
82
82
|
/** The page raises this type too, on its own error event, when the `Worker` fires `error`. */
|
|
83
83
|
readonly type: typeof WORKER_ERROR_MESSAGE_TYPE;
|
|
84
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* What the worker was doing, {@link WORKER_BOOTSTRAP_PHASE} for a failed
|
|
86
|
+
* bootstrap. The page's own report of a `Worker` `error` event carries
|
|
87
|
+
* `WORKER_ERROR_EVENT_PHASE`.
|
|
88
|
+
*/
|
|
85
89
|
readonly phase: string;
|
|
86
90
|
/** The failure described for a log. Never branch on it. */
|
|
87
91
|
readonly message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-handshake.d.ts","sourceRoot":"","sources":["../../src/client/worker-handshake.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEvE,gFAAgF;AAChF,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;AAEnE,qCAAqC;AACrC,MAAM,WAAW,SAAS;IACvB,QAAQ,CAAC,GAAG,EAAE,sBAAsB,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,s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;IAChC,8FAA8F;IAC9F,QAAQ,CAAC,IAAI,EAAE,OAAO,yBAAyB,CAAC;IAChD;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAMhF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-handshake.js","sourceRoot":"","sources":["../../src/client/worker-handshake.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;AAyBlF,gFAAgF;AACnE,QAAA,6BAA6B,GAAG,qBAAqB,CAAC;AAenE,kCAAyC,KAAc;IACpD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IAChB,CAAC;IACD,MAAM,SAAS,GAAG,KAAwC,CAAC;IAC3D,OAAO,SAAS,CAAC,IAAI,KAAK,QAAA,6BAA6B,IAAI,OAAO,SAAS,CAAC,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,KAAK,KAAK,IAAI,CAAC;AAC9H,CAAC;AAED;;;;;GAKG;AACU,QAAA,yBAAyB,GAAG,iBAAiB,CAAC;AAuB3D,8BAAqC,KAAc;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAAqC,CAAC,IAAI,KAAK,QAAA,yBAAyB,CAAC;AACnI,CAAC;AAED;;;;;;GAMG;AACU,QAAA,yBAAyB,GAAG,wBAAwB,CAAC;AAElE,4EAA4E;AAC/D,QAAA,sBAAsB,GAAG,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"worker-handshake.js","sourceRoot":"","sources":["../../src/client/worker-handshake.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;AAyBlF,gFAAgF;AACnE,QAAA,6BAA6B,GAAG,qBAAqB,CAAC;AAenE,kCAAyC,KAAc;IACpD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IAChB,CAAC;IACD,MAAM,SAAS,GAAG,KAAwC,CAAC;IAC3D,OAAO,SAAS,CAAC,IAAI,KAAK,QAAA,6BAA6B,IAAI,OAAO,SAAS,CAAC,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,KAAK,KAAK,IAAI,CAAC;AAC9H,CAAC;AAED;;;;;GAKG;AACU,QAAA,yBAAyB,GAAG,iBAAiB,CAAC;AAuB3D,8BAAqC,KAAc;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAAqC,CAAC,IAAI,KAAK,QAAA,yBAAyB,CAAC;AACnI,CAAC;AAED;;;;;;GAMG;AACU,QAAA,yBAAyB,GAAG,wBAAwB,CAAC;AAElE,4EAA4E;AAC/D,QAAA,sBAAsB,GAAG,WAAW,CAAC;AAelD,8BAAqC,KAAc;IAChD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IAChB,CAAC;IACD,MAAM,SAAS,GAAG,KAAoC,CAAC;IACvD,OAAO,SAAS,CAAC,IAAI,KAAK,QAAA,yBAAyB,IAAI,OAAO,SAAS,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,SAAS,CAAC,OAAO,KAAK,QAAQ,CAAC;AACvI,CAAC"}
|
package/lib/profile-session.d.ts
CHANGED
|
@@ -16,7 +16,11 @@ export interface ProfileRecord {
|
|
|
16
16
|
count: number;
|
|
17
17
|
/** Summed self-time across those runs (wall-clock minus nested scopes). */
|
|
18
18
|
selfMs: number;
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Self-time as a percentage of the session's total wall-clock. Overlapping
|
|
21
|
+
* scopes each count their own wall time, so the percentages can add up to
|
|
22
|
+
* more than 100.
|
|
23
|
+
*/
|
|
20
24
|
selfPct: number;
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
@@ -49,8 +53,9 @@ export interface ProfileSession {
|
|
|
49
53
|
/**
|
|
50
54
|
* Emit the aggregate through the bound {@link Logger}: one line per id,
|
|
51
55
|
* sorted by self-time descending, plus an "unaccounted" remainder (the
|
|
52
|
-
* session wall-clock not attributed to any top-level scope).
|
|
53
|
-
*
|
|
56
|
+
* session wall-clock not attributed to any top-level scope). The remainder
|
|
57
|
+
* is left out when overlapping scopes account for more than the wall-clock.
|
|
58
|
+
* No-op when `logLevel` is suppressed by the global threshold (incl. `'off'`).
|
|
54
59
|
*/
|
|
55
60
|
report(logLevel?: LogThreshold): void;
|
|
56
61
|
/** The same aggregate as structured records, for tests / programmatic use. */
|
|
@@ -79,11 +84,7 @@ export declare class DefaultProfileSession implements ProfileSession {
|
|
|
79
84
|
protected readonly identifier: string;
|
|
80
85
|
/** Single monotonic timeline for the whole session; per-scope readings are deltas off it. */
|
|
81
86
|
protected readonly sessionStopwatch: Stopwatch;
|
|
82
|
-
/**
|
|
83
|
-
* The scopes in flight, innermost last. They must end innermost first:
|
|
84
|
-
* {@link closeFrame} pops the top frame whichever scope ends, so
|
|
85
|
-
* overlapping async scopes misattribute their time.
|
|
86
|
-
*/
|
|
87
|
+
/** The scopes in flight, in the order they started. */
|
|
87
88
|
protected readonly stack: ProfileScopeFrame[];
|
|
88
89
|
/** Self-time in milliseconds per id, one sample per closed scope, which {@link records} sums. */
|
|
89
90
|
protected readonly entries: Map<string, number[]>;
|
|
@@ -91,8 +92,9 @@ export declare class DefaultProfileSession implements ProfileSession {
|
|
|
91
92
|
scope<T>(id: string, fn: () => Promise<T>): Promise<T>;
|
|
92
93
|
scope<T>(id: string, fn: () => T): T;
|
|
93
94
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
95
|
+
* Remove `frame`, charge its full duration to the frame below it, and record
|
|
96
|
+
* its self-time. Overlapping scopes can together outlast the one below
|
|
97
|
+
* them, whose self-time is then zero rather than negative.
|
|
96
98
|
*/
|
|
97
99
|
protected closeFrame(frame: ProfileScopeFrame): void;
|
|
98
100
|
records(): readonly ProfileRecord[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-session.d.ts","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAU,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7D,iFAAiF;AACjF,MAAM,WAAW,aAAa;IAC3B,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,MAAM,EAAE,MAAM,CAAC;IACf
|
|
1
|
+
{"version":3,"file":"profile-session.d.ts","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAU,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7D,iFAAiF;AACjF,MAAM,WAAW,aAAa;IAC3B,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,cAAc;IAC5B;;;;;;;OAOG;IACH,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC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AAG,IAAI,CAiBnD;IAED,OAAO,IAAI,SAAS,aAAa,EAAE,CAQlC;IAED,MAAM,CAAC,QAAQ,GAAE,YAAsB,GAAG,IAAI,CAgB7C;CACH"}
|
package/lib/profile-session.js
CHANGED
|
@@ -20,11 +20,7 @@ class DefaultProfileSession {
|
|
|
20
20
|
identifier;
|
|
21
21
|
/** Single monotonic timeline for the whole session; per-scope readings are deltas off it. */
|
|
22
22
|
sessionStopwatch;
|
|
23
|
-
/**
|
|
24
|
-
* The scopes in flight, innermost last. They must end innermost first:
|
|
25
|
-
* {@link closeFrame} pops the top frame whichever scope ends, so
|
|
26
|
-
* overlapping async scopes misattribute their time.
|
|
27
|
-
*/
|
|
23
|
+
/** The scopes in flight, in the order they started. */
|
|
28
24
|
stack = [];
|
|
29
25
|
/** Self-time in milliseconds per id, one sample per closed scope, which {@link records} sums. */
|
|
30
26
|
entries = new Map();
|
|
@@ -57,17 +53,21 @@ class DefaultProfileSession {
|
|
|
57
53
|
return result;
|
|
58
54
|
}
|
|
59
55
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
56
|
+
* Remove `frame`, charge its full duration to the frame below it, and record
|
|
57
|
+
* its self-time. Overlapping scopes can together outlast the one below
|
|
58
|
+
* them, whose self-time is then zero rather than negative.
|
|
62
59
|
*/
|
|
63
60
|
closeFrame(frame) {
|
|
64
|
-
this.stack.
|
|
61
|
+
const index = this.stack.lastIndexOf(frame);
|
|
62
|
+
if (index >= 0) {
|
|
63
|
+
this.stack.splice(index, 1);
|
|
64
|
+
}
|
|
65
65
|
const duration = this.sessionStopwatch.elapsedMs - frame.start;
|
|
66
|
-
const parent = this.stack[
|
|
66
|
+
const parent = index > 0 ? this.stack[index - 1] : undefined;
|
|
67
67
|
if (parent) {
|
|
68
68
|
parent.childMs += duration;
|
|
69
69
|
}
|
|
70
|
-
const selfMs = duration - frame.childMs;
|
|
70
|
+
const selfMs = Math.max(0, duration - frame.childMs);
|
|
71
71
|
const samples = this.entries.get(frame.id);
|
|
72
72
|
if (samples) {
|
|
73
73
|
samples.push(selfMs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-session.js","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAGlF,qCAA6D;
|
|
1
|
+
{"version":3,"file":"profile-session.js","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAGlF,qCAA6D;AAyE7D;;;;GAIG;AACH;IASyB,MAAM;IAEN,UAAU;IAVhC,6FAA6F;IAC1E,gBAAgB,CAAY;IAC/C,uDAAuD;IACpC,KAAK,GAAwB,EAAE,CAAC;IACnD,iGAAiG;IAC9E,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IAEzD,YACsB,MAAc,EACjC,KAAY,EACO,UAAkB;sBAFlB,MAAM;0BAEN,UAAU;QAE7B,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAC7C,CAAC;IAID,KAAK,CAAI,EAAU,EAAE,EAAwB;QAC1C,MAAM,KAAK,GAAsB,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;QAC5F,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,IAAI,MAAsB,CAAC;QAC3B,IAAI,CAAC;YACF,MAAM,GAAG,EAAE,EAAE,CAAC;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACd,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACvB,MAAM,KAAK,CAAC;QACf,CAAC;QACD,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;YAC7B,OAAO,MAAM,CAAC,IAAI,CACf,KAAK,CAAC,EAAE;gBACL,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;gBACvB,OAAO,KAAK,CAA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AM,CAAC,OAAO,CAAC,KAAK,eAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACtI,CAAC;QACD,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC5E,MAAM,aAAa,GAAG,OAAO,GAAG,WAAW,CAAC;QAC5C,IAAI,aAAa,IAAI,GAAG,EAAE,CAAC;YACxB,MAAM,GAAG,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,aAAa,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1E,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU,mBAAmB,GAAG,KAAK,eAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QAC/F,CAAC;IACJ,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -102,7 +102,11 @@ export const WORKER_BOOTSTRAP_PHASE = 'bootstrap';
|
|
|
102
102
|
export interface WorkerErrorMessage {
|
|
103
103
|
/** The page raises this type too, on its own error event, when the `Worker` fires `error`. */
|
|
104
104
|
readonly type: typeof WORKER_ERROR_MESSAGE_TYPE;
|
|
105
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* What the worker was doing, {@link WORKER_BOOTSTRAP_PHASE} for a failed
|
|
107
|
+
* bootstrap. The page's own report of a `Worker` `error` event carries
|
|
108
|
+
* `WORKER_ERROR_EVENT_PHASE`.
|
|
109
|
+
*/
|
|
106
110
|
readonly phase: string;
|
|
107
111
|
/** The failure described for a log. Never branch on it. */
|
|
108
112
|
readonly message: string;
|
package/src/profile-session.ts
CHANGED
|
@@ -18,7 +18,11 @@ export interface ProfileRecord {
|
|
|
18
18
|
count: number;
|
|
19
19
|
/** Summed self-time across those runs (wall-clock minus nested scopes). */
|
|
20
20
|
selfMs: number;
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Self-time as a percentage of the session's total wall-clock. Overlapping
|
|
23
|
+
* scopes each count their own wall time, so the percentages can add up to
|
|
24
|
+
* more than 100.
|
|
25
|
+
*/
|
|
22
26
|
selfPct: number;
|
|
23
27
|
}
|
|
24
28
|
|
|
@@ -53,8 +57,9 @@ export interface ProfileSession {
|
|
|
53
57
|
/**
|
|
54
58
|
* Emit the aggregate through the bound {@link Logger}: one line per id,
|
|
55
59
|
* sorted by self-time descending, plus an "unaccounted" remainder (the
|
|
56
|
-
* session wall-clock not attributed to any top-level scope).
|
|
57
|
-
*
|
|
60
|
+
* session wall-clock not attributed to any top-level scope). The remainder
|
|
61
|
+
* is left out when overlapping scopes account for more than the wall-clock.
|
|
62
|
+
* No-op when `logLevel` is suppressed by the global threshold (incl. `'off'`).
|
|
58
63
|
*/
|
|
59
64
|
report(logLevel?: LogThreshold): void;
|
|
60
65
|
|
|
@@ -84,11 +89,7 @@ export interface ProfileScopeFrame {
|
|
|
84
89
|
export class DefaultProfileSession implements ProfileSession {
|
|
85
90
|
/** Single monotonic timeline for the whole session; per-scope readings are deltas off it. */
|
|
86
91
|
protected readonly sessionStopwatch: Stopwatch;
|
|
87
|
-
/**
|
|
88
|
-
* The scopes in flight, innermost last. They must end innermost first:
|
|
89
|
-
* {@link closeFrame} pops the top frame whichever scope ends, so
|
|
90
|
-
* overlapping async scopes misattribute their time.
|
|
91
|
-
*/
|
|
92
|
+
/** The scopes in flight, in the order they started. */
|
|
92
93
|
protected readonly stack: ProfileScopeFrame[] = [];
|
|
93
94
|
/** Self-time in milliseconds per id, one sample per closed scope, which {@link records} sums. */
|
|
94
95
|
protected readonly entries = new Map<string, number[]>();
|
|
@@ -130,17 +131,21 @@ export class DefaultProfileSession implements ProfileSession {
|
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
134
|
+
* Remove `frame`, charge its full duration to the frame below it, and record
|
|
135
|
+
* its self-time. Overlapping scopes can together outlast the one below
|
|
136
|
+
* them, whose self-time is then zero rather than negative.
|
|
135
137
|
*/
|
|
136
138
|
protected closeFrame(frame: ProfileScopeFrame): void {
|
|
137
|
-
this.stack.
|
|
139
|
+
const index = this.stack.lastIndexOf(frame);
|
|
140
|
+
if (index >= 0) {
|
|
141
|
+
this.stack.splice(index, 1);
|
|
142
|
+
}
|
|
138
143
|
const duration = this.sessionStopwatch.elapsedMs - frame.start;
|
|
139
|
-
const parent = this.stack[
|
|
144
|
+
const parent = index > 0 ? this.stack[index - 1] : undefined;
|
|
140
145
|
if (parent) {
|
|
141
146
|
parent.childMs += duration;
|
|
142
147
|
}
|
|
143
|
-
const selfMs = duration - frame.childMs;
|
|
148
|
+
const selfMs = Math.max(0, duration - frame.childMs);
|
|
144
149
|
const samples = this.entries.get(frame.id);
|
|
145
150
|
if (samples) {
|
|
146
151
|
samples.push(selfMs);
|