stats-gl 2.4.2 → 3.0.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/main.cjs +122 -55
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +122 -55
- package/dist/main.js.map +1 -1
- package/dist/panel.cjs +42 -19
- package/dist/panel.cjs.map +1 -1
- package/dist/panel.js +42 -19
- package/dist/panel.js.map +1 -1
- package/dist/stats-gl.d.ts +19 -8
- package/lib/main.ts +168 -66
- package/lib/panel.ts +66 -42
- package/package.json +1 -1
package/dist/panel.cjs
CHANGED
|
@@ -60,6 +60,7 @@ class Panel {
|
|
|
60
60
|
initializeCanvas() {
|
|
61
61
|
if (!this.context)
|
|
62
62
|
return;
|
|
63
|
+
this.context.imageSmoothingEnabled = false;
|
|
63
64
|
this.context.font = "bold " + 9 * this.PR + "px Helvetica,Arial,sans-serif";
|
|
64
65
|
this.context.textBaseline = "top";
|
|
65
66
|
this.gradient = this.createGradient();
|
|
@@ -67,51 +68,73 @@ class Panel {
|
|
|
67
68
|
this.context.fillRect(0, 0, this.WIDTH, this.HEIGHT);
|
|
68
69
|
this.context.fillStyle = this.fg;
|
|
69
70
|
this.context.fillText(this.name, this.TEXT_X, this.TEXT_Y);
|
|
70
|
-
this.context.fillStyle = this.fg;
|
|
71
|
-
this.context.fillRect(this.GRAPH_X, this.GRAPH_Y, this.GRAPH_WIDTH, this.GRAPH_HEIGHT);
|
|
72
71
|
this.context.fillStyle = this.bg;
|
|
73
72
|
this.context.globalAlpha = 0.9;
|
|
74
73
|
this.context.fillRect(this.GRAPH_X, this.GRAPH_Y, this.GRAPH_WIDTH, this.GRAPH_HEIGHT);
|
|
75
74
|
}
|
|
75
|
+
// Update only text portion
|
|
76
76
|
update(value, valueGraph, maxValue, maxGraph, decimals = 0) {
|
|
77
77
|
if (!this.context || !this.gradient)
|
|
78
78
|
return;
|
|
79
79
|
const min = Math.min(Infinity, value);
|
|
80
80
|
const max = Math.max(maxValue, value);
|
|
81
|
-
maxGraph = Math.max(maxGraph, valueGraph);
|
|
82
81
|
this.context.globalAlpha = 1;
|
|
83
82
|
this.context.fillStyle = this.bg;
|
|
84
83
|
this.context.fillRect(0, 0, this.WIDTH, this.GRAPH_Y);
|
|
85
84
|
this.context.fillStyle = this.fg;
|
|
86
85
|
this.context.fillText(
|
|
87
|
-
`${value.toFixed(decimals)} ${this.name} (${min.toFixed(decimals)}-${parseFloat(
|
|
88
|
-
max.toFixed(decimals)
|
|
89
|
-
)})`,
|
|
86
|
+
`${value.toFixed(decimals)} ${this.name} (${min.toFixed(decimals)}-${parseFloat(max.toFixed(decimals))})`,
|
|
90
87
|
this.TEXT_X,
|
|
91
88
|
this.TEXT_Y
|
|
92
89
|
);
|
|
90
|
+
}
|
|
91
|
+
// Update only graph portion
|
|
92
|
+
updateGraph(valueGraph, maxGraph) {
|
|
93
|
+
if (!this.context || !this.gradient)
|
|
94
|
+
return;
|
|
95
|
+
if (valueGraph === 0 && maxGraph === 0) {
|
|
96
|
+
maxGraph = 1;
|
|
97
|
+
}
|
|
98
|
+
maxGraph = Math.max(maxGraph, valueGraph, 0.1);
|
|
99
|
+
valueGraph = Math.max(valueGraph, 0);
|
|
100
|
+
const graphX = Math.round(this.GRAPH_X);
|
|
101
|
+
const graphY = Math.round(this.GRAPH_Y);
|
|
102
|
+
const graphWidth = Math.round(this.GRAPH_WIDTH);
|
|
103
|
+
const graphHeight = Math.round(this.GRAPH_HEIGHT);
|
|
104
|
+
const pr = Math.round(this.PR);
|
|
93
105
|
this.context.drawImage(
|
|
94
106
|
this.canvas,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
graphX + pr,
|
|
108
|
+
graphY,
|
|
109
|
+
graphWidth - pr,
|
|
110
|
+
graphHeight,
|
|
111
|
+
graphX,
|
|
112
|
+
graphY,
|
|
113
|
+
graphWidth - pr,
|
|
114
|
+
graphHeight
|
|
115
|
+
);
|
|
116
|
+
this.context.fillStyle = this.bg;
|
|
117
|
+
this.context.fillRect(
|
|
118
|
+
graphX + graphWidth - pr,
|
|
119
|
+
graphY,
|
|
120
|
+
pr,
|
|
121
|
+
graphHeight
|
|
122
|
+
);
|
|
123
|
+
const columnHeight = Math.min(
|
|
124
|
+
graphHeight,
|
|
125
|
+
Math.round(valueGraph / maxGraph * graphHeight)
|
|
103
126
|
);
|
|
104
|
-
const columnHeight = this.GRAPH_HEIGHT - (1 - valueGraph / maxGraph) * this.GRAPH_HEIGHT;
|
|
105
127
|
if (columnHeight > 0) {
|
|
106
|
-
this.context.globalAlpha =
|
|
128
|
+
this.context.globalAlpha = 0.9;
|
|
107
129
|
this.context.fillStyle = this.gradient;
|
|
108
130
|
this.context.fillRect(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
131
|
+
graphX + graphWidth - pr,
|
|
132
|
+
graphY + (graphHeight - columnHeight),
|
|
133
|
+
pr,
|
|
112
134
|
columnHeight
|
|
113
135
|
);
|
|
114
136
|
}
|
|
137
|
+
this.context.globalAlpha = 1;
|
|
115
138
|
}
|
|
116
139
|
}
|
|
117
140
|
exports.Panel = Panel;
|
package/dist/panel.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel.cjs","sources":["../lib/panel.ts"],"sourcesContent":null,"names":[],"mappings":";;AAAA,MAAM,MAAM;AAAA,EAiBR,YAAY,MAAc,IAAY,IAAY;AAC9C,SAAK,OAAO;AACZ,SAAK,KAAK;AACV,SAAK,KAAK;AACV,SAAK,WAAW;AAChB,SAAK,KAAK,KAAK,MAAM,OAAO,oBAAoB,CAAC;AAE5C,SAAA,QAAQ,KAAK,KAAK;AAClB,SAAA,SAAS,KAAK,KAAK;AACnB,SAAA,SAAS,IAAI,KAAK;AAClB,SAAA,SAAS,IAAI,KAAK;AAClB,SAAA,UAAU,IAAI,KAAK;AACnB,SAAA,UAA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,QACtB,UAAU,cAAc;AAAA,QACxB;AAAA,QACA;AAAA,MAAA;AAAA,IAER;AAEA,SAAK,QAAQ,cAAc;AAAA,EAC/B;AACJ;;"}
|
package/dist/panel.js
CHANGED
|
@@ -58,6 +58,7 @@ class Panel {
|
|
|
58
58
|
initializeCanvas() {
|
|
59
59
|
if (!this.context)
|
|
60
60
|
return;
|
|
61
|
+
this.context.imageSmoothingEnabled = false;
|
|
61
62
|
this.context.font = "bold " + 9 * this.PR + "px Helvetica,Arial,sans-serif";
|
|
62
63
|
this.context.textBaseline = "top";
|
|
63
64
|
this.gradient = this.createGradient();
|
|
@@ -65,51 +66,73 @@ class Panel {
|
|
|
65
66
|
this.context.fillRect(0, 0, this.WIDTH, this.HEIGHT);
|
|
66
67
|
this.context.fillStyle = this.fg;
|
|
67
68
|
this.context.fillText(this.name, this.TEXT_X, this.TEXT_Y);
|
|
68
|
-
this.context.fillStyle = this.fg;
|
|
69
|
-
this.context.fillRect(this.GRAPH_X, this.GRAPH_Y, this.GRAPH_WIDTH, this.GRAPH_HEIGHT);
|
|
70
69
|
this.context.fillStyle = this.bg;
|
|
71
70
|
this.context.globalAlpha = 0.9;
|
|
72
71
|
this.context.fillRect(this.GRAPH_X, this.GRAPH_Y, this.GRAPH_WIDTH, this.GRAPH_HEIGHT);
|
|
73
72
|
}
|
|
73
|
+
// Update only text portion
|
|
74
74
|
update(value, valueGraph, maxValue, maxGraph, decimals = 0) {
|
|
75
75
|
if (!this.context || !this.gradient)
|
|
76
76
|
return;
|
|
77
77
|
const min = Math.min(Infinity, value);
|
|
78
78
|
const max = Math.max(maxValue, value);
|
|
79
|
-
maxGraph = Math.max(maxGraph, valueGraph);
|
|
80
79
|
this.context.globalAlpha = 1;
|
|
81
80
|
this.context.fillStyle = this.bg;
|
|
82
81
|
this.context.fillRect(0, 0, this.WIDTH, this.GRAPH_Y);
|
|
83
82
|
this.context.fillStyle = this.fg;
|
|
84
83
|
this.context.fillText(
|
|
85
|
-
`${value.toFixed(decimals)} ${this.name} (${min.toFixed(decimals)}-${parseFloat(
|
|
86
|
-
max.toFixed(decimals)
|
|
87
|
-
)})`,
|
|
84
|
+
`${value.toFixed(decimals)} ${this.name} (${min.toFixed(decimals)}-${parseFloat(max.toFixed(decimals))})`,
|
|
88
85
|
this.TEXT_X,
|
|
89
86
|
this.TEXT_Y
|
|
90
87
|
);
|
|
88
|
+
}
|
|
89
|
+
// Update only graph portion
|
|
90
|
+
updateGraph(valueGraph, maxGraph) {
|
|
91
|
+
if (!this.context || !this.gradient)
|
|
92
|
+
return;
|
|
93
|
+
if (valueGraph === 0 && maxGraph === 0) {
|
|
94
|
+
maxGraph = 1;
|
|
95
|
+
}
|
|
96
|
+
maxGraph = Math.max(maxGraph, valueGraph, 0.1);
|
|
97
|
+
valueGraph = Math.max(valueGraph, 0);
|
|
98
|
+
const graphX = Math.round(this.GRAPH_X);
|
|
99
|
+
const graphY = Math.round(this.GRAPH_Y);
|
|
100
|
+
const graphWidth = Math.round(this.GRAPH_WIDTH);
|
|
101
|
+
const graphHeight = Math.round(this.GRAPH_HEIGHT);
|
|
102
|
+
const pr = Math.round(this.PR);
|
|
91
103
|
this.context.drawImage(
|
|
92
104
|
this.canvas,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
graphX + pr,
|
|
106
|
+
graphY,
|
|
107
|
+
graphWidth - pr,
|
|
108
|
+
graphHeight,
|
|
109
|
+
graphX,
|
|
110
|
+
graphY,
|
|
111
|
+
graphWidth - pr,
|
|
112
|
+
graphHeight
|
|
113
|
+
);
|
|
114
|
+
this.context.fillStyle = this.bg;
|
|
115
|
+
this.context.fillRect(
|
|
116
|
+
graphX + graphWidth - pr,
|
|
117
|
+
graphY,
|
|
118
|
+
pr,
|
|
119
|
+
graphHeight
|
|
120
|
+
);
|
|
121
|
+
const columnHeight = Math.min(
|
|
122
|
+
graphHeight,
|
|
123
|
+
Math.round(valueGraph / maxGraph * graphHeight)
|
|
101
124
|
);
|
|
102
|
-
const columnHeight = this.GRAPH_HEIGHT - (1 - valueGraph / maxGraph) * this.GRAPH_HEIGHT;
|
|
103
125
|
if (columnHeight > 0) {
|
|
104
|
-
this.context.globalAlpha =
|
|
126
|
+
this.context.globalAlpha = 0.9;
|
|
105
127
|
this.context.fillStyle = this.gradient;
|
|
106
128
|
this.context.fillRect(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
129
|
+
graphX + graphWidth - pr,
|
|
130
|
+
graphY + (graphHeight - columnHeight),
|
|
131
|
+
pr,
|
|
110
132
|
columnHeight
|
|
111
133
|
);
|
|
112
134
|
}
|
|
135
|
+
this.context.globalAlpha = 1;
|
|
113
136
|
}
|
|
114
137
|
}
|
|
115
138
|
export {
|
package/dist/panel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel.js","sources":["../lib/panel.ts"],"sourcesContent":null,"names":[],"mappings":"AAAA,MAAM,MAAM;AAAA,EAiBR,YAAY,MAAc,IAAY,IAAY;AAC9C,SAAK,OAAO;AACZ,SAAK,KAAK;AACV,SAAK,KAAK;AACV,SAAK,WAAW;AAChB,SAAK,KAAK,KAAK,MAAM,OAAO,oBAAoB,CAAC;AAE5C,SAAA,QAAQ,KAAK,KAAK;AAClB,SAAA,SAAS,KAAK,KAAK;AACnB,SAAA,SAAS,IAAI,KAAK;AAClB,SAAA,SAAS,IAAI,KAAK;AAClB,SAAA,UAAU,IAAI,KAAK;AACnB,SAAA,UAAU,KAAK,KAAK;AACpB,SAAA,cAAc,KAAK,KAAK;AACxB,SAAA,eAAe,KAAK,KAAK;AAEzB,SAAA,SAAS,SAAS,cAAc,QAAQ;AACxC,SAAA,OAAO,QAAQ,KAAK;AACpB,SAAA,OAAO,SAAS,KAAK;AACrB,SAAA,OAAO,MAAM,QAAQ;AACrB,SAAA,OAAO,MAAM,SAAS;AACtB,SAAA,OAAO,MAAM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ACL,KAAK;AAAA,IAAA;AAAA,EAEb;AAAA;AAAA,EAGA,YAAY,YAAoB,UAAkB;AAC9C,QAAI,CAAC,KAAK,WAAW,CAAC,KAAK;AAAU;AAGjC,QAAA,eAAe,KAAK,aAAa,GAAG;AACzB,iBAAA;AAAA,IACf;AAGA,eAAW,KAAK,IAAI,UAAU,YAAY,GAAG;AAChC,iBAAA,KAAK,IAAI,YAAY,CAAC;AAGnC,UAAM,SAAS,KAAK,MAAM,KAAK,OAAO;AACtC,UAAM,SAAS,KAAK,MAAM,KAAK,OAAO;AACtC,UAAM,aAAa,KAAK,MAAM,KAAK,WAAW;AAC9C,UAAM,cAAc,KAAK,MAAM,KAAK,YAAY;AAChD,UAAM,KAAK,KAAK,MAAM,KAAK,EAAE;AAG7B,SAAK,QAAQ;AAAA,MACT,KAAK;AAAA,MACL,SAAS;AAAA,MACT;AAAA,MACA,aAAa;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa;AAAA,MACb;AAAA,IAAA;AAIC,SAAA,QAAQ,YAAY,KAAK;AAC9B,SAAK,QAAQ;AAAA,MACT,SAAS,aAAa;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAIJ,UAAM,eAAe,KAAK;AAAA,MACtB;AAAA,MACA,KAAK,MAAM,aAAa,WAAW,WAAW;AAAA,IAAA;AAIlD,QAAI,eAAe,GAAG;AAClB,WAAK,QAAQ,cAAc;AACtB,WAAA,QAAQ,YAAY,KAAK;AAC9B,WAAK,QAAQ;AAAA,QACT,SAAS,aAAa;AAAA,QACtB,UAAU,cAAc;AAAA,QACxB;AAAA,QACA;AAAA,MAAA;AAAA,IAER;AAEA,SAAK,QAAQ,cAAc;AAAA,EAC/B;AACJ;"}
|
package/dist/stats-gl.d.ts
CHANGED
|
@@ -18,11 +18,13 @@ declare class Panel {
|
|
|
18
18
|
private createGradient;
|
|
19
19
|
private initializeCanvas;
|
|
20
20
|
update(value: number, valueGraph: number, maxValue: number, maxGraph: number, decimals?: number): void;
|
|
21
|
+
updateGraph(valueGraph: number, maxGraph: number): void;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
interface StatsOptions {
|
|
24
25
|
trackGPU?: boolean;
|
|
25
26
|
logsPerSecond?: number;
|
|
27
|
+
graphsPerSecond?: number;
|
|
26
28
|
samplesLog?: number;
|
|
27
29
|
samplesGraph?: number;
|
|
28
30
|
precision?: number;
|
|
@@ -40,6 +42,7 @@ declare class Stats {
|
|
|
40
42
|
private samplesGraph;
|
|
41
43
|
private precision;
|
|
42
44
|
private logsPerSecond;
|
|
45
|
+
private graphsPerSecond;
|
|
43
46
|
private gl;
|
|
44
47
|
private ext;
|
|
45
48
|
private info?;
|
|
@@ -49,13 +52,12 @@ declare class Stats {
|
|
|
49
52
|
private beginTime;
|
|
50
53
|
private prevTime;
|
|
51
54
|
private prevCpuTime;
|
|
52
|
-
private
|
|
55
|
+
private frameTimes;
|
|
53
56
|
private renderCount;
|
|
54
57
|
private isRunningCPUProfiling;
|
|
55
58
|
private totalCpuDuration;
|
|
56
59
|
private totalGpuDuration;
|
|
57
60
|
private totalGpuDurationCompute;
|
|
58
|
-
private totalFps;
|
|
59
61
|
private fpsPanel;
|
|
60
62
|
private msPanel;
|
|
61
63
|
private gpuPanel;
|
|
@@ -64,8 +66,14 @@ declare class Stats {
|
|
|
64
66
|
private averageCpu;
|
|
65
67
|
private averageGpu;
|
|
66
68
|
private averageGpuCompute;
|
|
69
|
+
private updateCounter;
|
|
70
|
+
private prevGraphTime;
|
|
71
|
+
private lastMin;
|
|
72
|
+
private lastMax;
|
|
73
|
+
private lastValue;
|
|
74
|
+
private prevTextTime;
|
|
67
75
|
static Panel: typeof Panel;
|
|
68
|
-
constructor({ trackGPU, logsPerSecond, samplesLog, samplesGraph, precision, minimal, horizontal, mode }?: StatsOptions);
|
|
76
|
+
constructor({ trackGPU, logsPerSecond, graphsPerSecond, samplesLog, samplesGraph, precision, minimal, horizontal, mode }?: StatsOptions);
|
|
69
77
|
private initializeDOM;
|
|
70
78
|
private setupEventListeners;
|
|
71
79
|
private handleClick;
|
|
@@ -80,25 +88,28 @@ declare class Stats {
|
|
|
80
88
|
end(): void;
|
|
81
89
|
update(): void;
|
|
82
90
|
private processWebGPUTimestamps;
|
|
83
|
-
private updateAverages;
|
|
84
91
|
private resetCounters;
|
|
85
92
|
resizePanel(panel: Panel, offset: number): void;
|
|
86
93
|
addPanel(panel: Panel, offset: number): Panel;
|
|
87
94
|
showPanel(id: number): void;
|
|
88
95
|
processGpuQueries(): void;
|
|
89
96
|
endInternal(): number;
|
|
90
|
-
|
|
91
|
-
logs: any;
|
|
92
|
-
graph: any;
|
|
93
|
-
}): void;
|
|
97
|
+
private updatePanelComponents;
|
|
94
98
|
beginProfiling(marker: string): void;
|
|
95
99
|
endProfiling(startMarker: string | PerformanceMeasureOptions | undefined, endMarker: string | undefined, measureName: string): void;
|
|
96
100
|
updatePanel(panel: {
|
|
97
101
|
update: any;
|
|
102
|
+
updateGraph: any;
|
|
103
|
+
name: string;
|
|
98
104
|
} | null, averageArray: {
|
|
99
105
|
logs: number[];
|
|
100
106
|
graph: number[];
|
|
101
107
|
}, precision?: number): void;
|
|
108
|
+
private updateAverages;
|
|
109
|
+
addToAverage(value: number, averageArray: {
|
|
110
|
+
logs: any;
|
|
111
|
+
graph: any;
|
|
112
|
+
}): void;
|
|
102
113
|
get domElement(): HTMLDivElement;
|
|
103
114
|
patchThreeRenderer(renderer: any): void;
|
|
104
115
|
}
|
package/lib/main.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Panel } from './panel';
|
|
|
4
4
|
interface StatsOptions {
|
|
5
5
|
trackGPU?: boolean;
|
|
6
6
|
logsPerSecond?: number;
|
|
7
|
+
graphsPerSecond?: number;
|
|
7
8
|
samplesLog?: number;
|
|
8
9
|
samplesGraph?: number;
|
|
9
10
|
precision?: number;
|
|
@@ -40,6 +41,7 @@ class Stats {
|
|
|
40
41
|
private samplesGraph: number;
|
|
41
42
|
private precision: number;
|
|
42
43
|
private logsPerSecond: number;
|
|
44
|
+
private graphsPerSecond: number;
|
|
43
45
|
|
|
44
46
|
private gl: WebGL2RenderingContext | null = null;
|
|
45
47
|
private ext: any | null = null;
|
|
@@ -51,14 +53,14 @@ class Stats {
|
|
|
51
53
|
private beginTime: number;
|
|
52
54
|
private prevTime: number;
|
|
53
55
|
private prevCpuTime: number;
|
|
54
|
-
private
|
|
56
|
+
private frameTimes: number[] = []; // Store frame timestamps
|
|
57
|
+
|
|
55
58
|
private renderCount = 0;
|
|
56
59
|
private isRunningCPUProfiling = false;
|
|
57
60
|
|
|
58
61
|
private totalCpuDuration = 0;
|
|
59
62
|
private totalGpuDuration = 0;
|
|
60
63
|
private totalGpuDurationCompute = 0;
|
|
61
|
-
private totalFps = 0;
|
|
62
64
|
|
|
63
65
|
private fpsPanel: Panel;
|
|
64
66
|
private msPanel: Panel;
|
|
@@ -70,12 +72,21 @@ class Stats {
|
|
|
70
72
|
private averageGpu: AverageData = { logs: [], graph: [] };
|
|
71
73
|
private averageGpuCompute: AverageData = { logs: [], graph: [] };
|
|
72
74
|
|
|
75
|
+
private updateCounter = 0;
|
|
76
|
+
private prevGraphTime: number;
|
|
77
|
+
private lastMin: { [key: string]: number } = {};
|
|
78
|
+
private lastMax: { [key: string]: number } = {};
|
|
79
|
+
private lastValue: { [key: string]: number } = {};
|
|
80
|
+
private prevTextTime: number;
|
|
81
|
+
|
|
82
|
+
|
|
73
83
|
static Panel = Panel;
|
|
74
84
|
|
|
75
85
|
constructor({
|
|
76
86
|
trackGPU = false,
|
|
77
|
-
logsPerSecond =
|
|
78
|
-
|
|
87
|
+
logsPerSecond = 4,
|
|
88
|
+
graphsPerSecond = 30,
|
|
89
|
+
samplesLog = 40,
|
|
79
90
|
samplesGraph = 10,
|
|
80
91
|
precision = 2,
|
|
81
92
|
minimal = false,
|
|
@@ -90,6 +101,9 @@ class Stats {
|
|
|
90
101
|
this.samplesGraph = samplesGraph;
|
|
91
102
|
this.precision = precision;
|
|
92
103
|
this.logsPerSecond = logsPerSecond;
|
|
104
|
+
this.graphsPerSecond = graphsPerSecond;
|
|
105
|
+
const prevGraphTime = performance.now();
|
|
106
|
+
this.prevGraphTime = prevGraphTime
|
|
93
107
|
|
|
94
108
|
// Initialize DOM
|
|
95
109
|
this.dom = document.createElement('div');
|
|
@@ -98,6 +112,8 @@ class Stats {
|
|
|
98
112
|
// Initialize timing
|
|
99
113
|
this.beginTime = performance.now();
|
|
100
114
|
this.prevTime = this.beginTime;
|
|
115
|
+
this.prevTextTime = this.beginTime;
|
|
116
|
+
|
|
101
117
|
this.prevCpuTime = this.beginTime;
|
|
102
118
|
|
|
103
119
|
// Create panels
|
|
@@ -248,39 +264,35 @@ class Stats {
|
|
|
248
264
|
}
|
|
249
265
|
|
|
250
266
|
public update(): void {
|
|
267
|
+
// Always end the current CPU profiling if it's running
|
|
268
|
+
if (this.isRunningCPUProfiling) {
|
|
269
|
+
this.endProfiling('cpu-started', 'cpu-finished', 'cpu-duration');
|
|
270
|
+
// Add to averages immediately after getting the duration
|
|
271
|
+
// this.addToAverage(this.totalCpuDuration, this.averageCpu);
|
|
272
|
+
}
|
|
273
|
+
|
|
251
274
|
if (!this.info) {
|
|
252
275
|
this.processGpuQueries();
|
|
253
276
|
} else {
|
|
254
277
|
this.processWebGPUTimestamps();
|
|
255
278
|
}
|
|
256
279
|
|
|
257
|
-
this.
|
|
258
|
-
this.updateAverages();
|
|
280
|
+
this.updateAverages()
|
|
259
281
|
this.resetCounters();
|
|
260
282
|
}
|
|
261
283
|
|
|
262
284
|
private processWebGPUTimestamps(): void {
|
|
263
285
|
this.totalGpuDuration = this.info!.render.timestamp;
|
|
264
286
|
this.totalGpuDurationCompute = this.info!.compute.timestamp;
|
|
265
|
-
this.addToAverage(this.totalGpuDurationCompute, this.averageGpuCompute);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
private updateAverages(): void {
|
|
269
|
-
this.addToAverage(this.totalCpuDuration, this.averageCpu);
|
|
270
|
-
this.addToAverage(this.totalGpuDuration, this.averageGpu);
|
|
271
287
|
}
|
|
272
288
|
|
|
273
289
|
private resetCounters(): void {
|
|
274
290
|
this.renderCount = 0;
|
|
275
|
-
if (this.totalCpuDuration === 0) {
|
|
276
|
-
this.beginProfiling('cpu-started');
|
|
277
|
-
}
|
|
278
291
|
this.totalCpuDuration = 0;
|
|
279
|
-
this.
|
|
292
|
+
this.beginProfiling('cpu-started');
|
|
280
293
|
this.beginTime = this.endInternal();
|
|
281
294
|
}
|
|
282
295
|
|
|
283
|
-
|
|
284
296
|
resizePanel(panel: Panel, offset: number) {
|
|
285
297
|
|
|
286
298
|
panel.canvas.style.position = 'absolute';
|
|
@@ -355,54 +367,95 @@ class Stats {
|
|
|
355
367
|
}
|
|
356
368
|
|
|
357
369
|
endInternal() {
|
|
370
|
+
const currentTime = performance.now();
|
|
358
371
|
|
|
359
|
-
this.
|
|
360
|
-
const time = (performance || Date).now();
|
|
361
|
-
const elapsed = time - this.prevTime;
|
|
372
|
+
this.frameTimes.push(currentTime);
|
|
362
373
|
|
|
363
|
-
//
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
374
|
+
// Remove frames older than 1 second
|
|
375
|
+
while (this.frameTimes.length > 0 && this.frameTimes[0] <= currentTime - 1000) {
|
|
376
|
+
this.frameTimes.shift();
|
|
377
|
+
}
|
|
367
378
|
|
|
368
|
-
|
|
369
|
-
|
|
379
|
+
// Calculate FPS based on frames in the last second
|
|
380
|
+
const fps = Math.round(this.frameTimes.length);
|
|
370
381
|
|
|
371
|
-
|
|
372
|
-
this.updatePanel(this.fpsPanel, this.averageFps, 0);
|
|
373
|
-
this.updatePanel(this.msPanel, this.averageCpu, this.precision);
|
|
374
|
-
this.updatePanel(this.gpuPanel, this.averageGpu, this.precision);
|
|
382
|
+
this.addToAverage(fps, this.averageFps);
|
|
375
383
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
384
|
+
const shouldUpdateText = currentTime >= this.prevTextTime + 1000 / this.logsPerSecond;
|
|
385
|
+
const shouldUpdateGraph = currentTime >= this.prevGraphTime + 1000 / this.graphsPerSecond;
|
|
379
386
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
this.
|
|
387
|
+
this.updatePanelComponents(this.fpsPanel, this.averageFps, 0, shouldUpdateText, shouldUpdateGraph);
|
|
388
|
+
this.updatePanelComponents(this.msPanel, this.averageCpu, this.precision, shouldUpdateText, shouldUpdateGraph);
|
|
389
|
+
if (this.gpuPanel) {
|
|
390
|
+
this.updatePanelComponents(this.gpuPanel, this.averageGpu, this.precision, shouldUpdateText, shouldUpdateGraph);
|
|
391
|
+
}
|
|
392
|
+
if (this.gpuPanelCompute) {
|
|
393
|
+
this.updatePanelComponents(this.gpuPanelCompute, this.averageGpuCompute, this.precision, shouldUpdateText, shouldUpdateGraph);
|
|
384
394
|
}
|
|
385
395
|
|
|
386
|
-
|
|
396
|
+
if (shouldUpdateText) {
|
|
397
|
+
this.prevTextTime = currentTime;
|
|
398
|
+
}
|
|
399
|
+
if (shouldUpdateGraph) {
|
|
400
|
+
this.prevGraphTime = currentTime;
|
|
401
|
+
}
|
|
387
402
|
|
|
403
|
+
return currentTime;
|
|
388
404
|
}
|
|
389
405
|
|
|
390
|
-
|
|
406
|
+
private updatePanelComponents(
|
|
407
|
+
panel: Panel | null,
|
|
408
|
+
averageArray: { logs: number[], graph: number[] },
|
|
409
|
+
precision: number,
|
|
410
|
+
shouldUpdateText: boolean,
|
|
411
|
+
shouldUpdateGraph: boolean
|
|
412
|
+
) {
|
|
413
|
+
if (!panel || averageArray.logs.length === 0) return;
|
|
414
|
+
|
|
415
|
+
// Initialize tracking for this panel if not exists
|
|
416
|
+
if (!(panel.name in this.lastMin)) {
|
|
417
|
+
this.lastMin[panel.name] = Infinity;
|
|
418
|
+
this.lastMax[panel.name] = 0;
|
|
419
|
+
this.lastValue[panel.name] = 0;
|
|
420
|
+
}
|
|
391
421
|
|
|
392
|
-
averageArray.logs.
|
|
393
|
-
|
|
422
|
+
const currentValue = averageArray.logs[averageArray.logs.length - 1];
|
|
423
|
+
const recentMax = Math.max(...averageArray.logs.slice(-30));
|
|
394
424
|
|
|
395
|
-
|
|
425
|
+
this.lastMin[panel.name] = Math.min(this.lastMin[panel.name], currentValue);
|
|
426
|
+
this.lastMax[panel.name] = Math.max(this.lastMax[panel.name], currentValue);
|
|
396
427
|
|
|
397
|
-
|
|
428
|
+
// Smooth the display value
|
|
429
|
+
this.lastValue[panel.name] = this.lastValue[panel.name] * 0.7 + currentValue * 0.3;
|
|
398
430
|
|
|
399
|
-
averageArray.graph.
|
|
400
|
-
if (averageArray.graph.length > this.samplesGraph) {
|
|
431
|
+
const graphMax = Math.max(recentMax, ...averageArray.graph.slice(-this.samplesGraph));
|
|
401
432
|
|
|
402
|
-
|
|
433
|
+
this.updateCounter++;
|
|
403
434
|
|
|
435
|
+
// Reset min/max periodically
|
|
436
|
+
if (this.updateCounter % (this.logsPerSecond * 2) === 0) {
|
|
437
|
+
this.lastMax[panel.name] = recentMax;
|
|
438
|
+
this.lastMin[panel.name] = currentValue;
|
|
404
439
|
}
|
|
405
440
|
|
|
441
|
+
// Update text if it's time
|
|
442
|
+
if (shouldUpdateText) {
|
|
443
|
+
panel.update(
|
|
444
|
+
this.lastValue[panel.name],
|
|
445
|
+
currentValue,
|
|
446
|
+
this.lastMax[panel.name],
|
|
447
|
+
graphMax,
|
|
448
|
+
precision
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// Update graph if it's time
|
|
453
|
+
if (shouldUpdateGraph) {
|
|
454
|
+
panel.updateGraph(
|
|
455
|
+
currentValue,
|
|
456
|
+
graphMax
|
|
457
|
+
);
|
|
458
|
+
}
|
|
406
459
|
}
|
|
407
460
|
|
|
408
461
|
beginProfiling(marker: string) {
|
|
@@ -429,39 +482,88 @@ class Stats {
|
|
|
429
482
|
|
|
430
483
|
}
|
|
431
484
|
|
|
432
|
-
updatePanel(panel: { update: any; } | null, averageArray: { logs: number[], graph: number[] }, precision = 2) {
|
|
485
|
+
updatePanel(panel: { update: any; updateGraph: any; name: string; } | null, averageArray: { logs: number[], graph: number[] }, precision = 2) {
|
|
486
|
+
if (!panel || averageArray.logs.length === 0) return;
|
|
433
487
|
|
|
434
|
-
|
|
488
|
+
const currentTime = performance.now();
|
|
435
489
|
|
|
436
|
-
|
|
437
|
-
|
|
490
|
+
// Initialize tracking for this panel if not exists
|
|
491
|
+
if (!(panel.name in this.lastMin)) {
|
|
492
|
+
this.lastMin[panel.name] = Infinity;
|
|
493
|
+
this.lastMax[panel.name] = 0;
|
|
494
|
+
this.lastValue[panel.name] = 0;
|
|
495
|
+
}
|
|
438
496
|
|
|
439
|
-
|
|
497
|
+
// Get the current value and recent max
|
|
498
|
+
const currentValue = averageArray.logs[averageArray.logs.length - 1];
|
|
499
|
+
const recentMax = Math.max(...averageArray.logs.slice(-30));
|
|
440
500
|
|
|
441
|
-
|
|
501
|
+
// Update running statistics
|
|
502
|
+
this.lastMin[panel.name] = Math.min(this.lastMin[panel.name], currentValue);
|
|
503
|
+
this.lastMax[panel.name] = Math.max(this.lastMax[panel.name], currentValue);
|
|
442
504
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}
|
|
505
|
+
// Smooth the display value
|
|
506
|
+
this.lastValue[panel.name] = this.lastValue[panel.name] * 0.7 + currentValue * 0.3;
|
|
446
507
|
|
|
447
|
-
|
|
508
|
+
// Calculate graph scaling value
|
|
509
|
+
const graphMax = Math.max(recentMax, ...averageArray.graph.slice(-this.samplesGraph));
|
|
448
510
|
|
|
449
|
-
|
|
450
|
-
let maxGraph = 0.01;
|
|
451
|
-
for (let i = 0; i < averageArray.graph.length; i++) {
|
|
511
|
+
this.updateCounter++;
|
|
452
512
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
513
|
+
// Reset min/max periodically
|
|
514
|
+
if (this.updateCounter % (this.logsPerSecond * 2) === 0) {
|
|
515
|
+
this.lastMax[panel.name] = recentMax;
|
|
516
|
+
this.lastMin[panel.name] = currentValue;
|
|
517
|
+
}
|
|
458
518
|
|
|
519
|
+
if (panel.update) {
|
|
520
|
+
// Check if it's time to update the text (based on logsPerSecond)
|
|
521
|
+
if (currentTime >= this.prevCpuTime + 1000 / this.logsPerSecond) {
|
|
522
|
+
panel.update(
|
|
523
|
+
this.lastValue[panel.name],
|
|
524
|
+
currentValue,
|
|
525
|
+
this.lastMax[panel.name],
|
|
526
|
+
graphMax,
|
|
527
|
+
precision
|
|
528
|
+
);
|
|
459
529
|
}
|
|
460
530
|
|
|
461
|
-
if (
|
|
462
|
-
|
|
531
|
+
// Check if it's time to update the graph (based on graphsPerSecond)
|
|
532
|
+
if (currentTime >= this.prevGraphTime + 1000 / this.graphsPerSecond) {
|
|
533
|
+
panel.updateGraph(
|
|
534
|
+
currentValue,
|
|
535
|
+
graphMax
|
|
536
|
+
);
|
|
537
|
+
this.prevGraphTime = currentTime;
|
|
463
538
|
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
private updateAverages(): void {
|
|
543
|
+
this.addToAverage(this.totalCpuDuration, this.averageCpu);
|
|
544
|
+
this.addToAverage(this.totalGpuDuration, this.averageGpu);
|
|
545
|
+
// Add GPU Compute to the main update flow
|
|
546
|
+
if (this.info && this.totalGpuDurationCompute !== undefined) {
|
|
547
|
+
this.addToAverage(this.totalGpuDurationCompute, this.averageGpuCompute);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
addToAverage(value: number, averageArray: { logs: any; graph: any; }) {
|
|
552
|
+
// Validate value
|
|
553
|
+
// if (value === undefined || value === null || isNaN(value)) {
|
|
554
|
+
// return;
|
|
555
|
+
// }
|
|
464
556
|
|
|
557
|
+
// Store raw values for logs
|
|
558
|
+
averageArray.logs.push(value);
|
|
559
|
+
if (averageArray.logs.length > this.samplesLog) {
|
|
560
|
+
averageArray.logs = averageArray.logs.slice(-this.samplesLog);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// For graph, store raw values
|
|
564
|
+
averageArray.graph.push(value);
|
|
565
|
+
if (averageArray.graph.length > this.samplesGraph) {
|
|
566
|
+
averageArray.graph = averageArray.graph.slice(-this.samplesGraph);
|
|
465
567
|
}
|
|
466
568
|
}
|
|
467
569
|
|