stats-gl 2.4.1 → 3.0.0
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 +123 -55
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +123 -55
- package/dist/main.js.map +1 -1
- package/dist/panel.cjs +42 -17
- package/dist/panel.cjs.map +1 -1
- package/dist/panel.js +42 -17
- package/dist/panel.js.map +1 -1
- package/dist/stats-gl.d.ts +20 -8
- package/lib/main.ts +169 -63
- package/lib/panel.ts +66 -40
- 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();
|
|
@@ -73,45 +74,69 @@ class Panel {
|
|
|
73
74
|
this.context.globalAlpha = 0.9;
|
|
74
75
|
this.context.fillRect(this.GRAPH_X, this.GRAPH_Y, this.GRAPH_WIDTH, this.GRAPH_HEIGHT);
|
|
75
76
|
}
|
|
77
|
+
// Update only text portion
|
|
76
78
|
update(value, valueGraph, maxValue, maxGraph, decimals = 0) {
|
|
77
79
|
if (!this.context || !this.gradient)
|
|
78
80
|
return;
|
|
79
81
|
const min = Math.min(Infinity, value);
|
|
80
82
|
const max = Math.max(maxValue, value);
|
|
81
|
-
maxGraph = Math.max(maxGraph, valueGraph);
|
|
82
83
|
this.context.globalAlpha = 1;
|
|
83
84
|
this.context.fillStyle = this.bg;
|
|
84
85
|
this.context.fillRect(0, 0, this.WIDTH, this.GRAPH_Y);
|
|
85
86
|
this.context.fillStyle = this.fg;
|
|
86
87
|
this.context.fillText(
|
|
87
|
-
`${value.toFixed(decimals)} ${this.name} (${min.toFixed(decimals)}-${parseFloat(
|
|
88
|
-
max.toFixed(decimals)
|
|
89
|
-
)})`,
|
|
88
|
+
`${value.toFixed(decimals)} ${this.name} (${min.toFixed(decimals)}-${parseFloat(max.toFixed(decimals))})`,
|
|
90
89
|
this.TEXT_X,
|
|
91
90
|
this.TEXT_Y
|
|
92
91
|
);
|
|
92
|
+
}
|
|
93
|
+
// Update only graph portion
|
|
94
|
+
updateGraph(valueGraph, maxGraph) {
|
|
95
|
+
if (!this.context || !this.gradient)
|
|
96
|
+
return;
|
|
97
|
+
if (valueGraph === 0 && maxGraph === 0) {
|
|
98
|
+
maxGraph = 1;
|
|
99
|
+
}
|
|
100
|
+
maxGraph = Math.max(maxGraph, valueGraph, 0.1);
|
|
101
|
+
valueGraph = Math.max(valueGraph, 0);
|
|
102
|
+
const graphX = Math.round(this.GRAPH_X);
|
|
103
|
+
const graphY = Math.round(this.GRAPH_Y);
|
|
104
|
+
const graphWidth = Math.round(this.GRAPH_WIDTH);
|
|
105
|
+
const graphHeight = Math.round(this.GRAPH_HEIGHT);
|
|
106
|
+
const pr = Math.round(this.PR);
|
|
93
107
|
this.context.drawImage(
|
|
94
108
|
this.canvas,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
109
|
+
graphX + pr,
|
|
110
|
+
graphY,
|
|
111
|
+
graphWidth - pr,
|
|
112
|
+
graphHeight,
|
|
113
|
+
graphX,
|
|
114
|
+
graphY,
|
|
115
|
+
graphWidth - pr,
|
|
116
|
+
graphHeight
|
|
117
|
+
);
|
|
118
|
+
this.context.fillStyle = this.bg;
|
|
119
|
+
this.context.fillRect(
|
|
120
|
+
graphX + graphWidth - pr,
|
|
121
|
+
graphY,
|
|
122
|
+
pr,
|
|
123
|
+
graphHeight
|
|
124
|
+
);
|
|
125
|
+
const columnHeight = Math.min(
|
|
126
|
+
graphHeight,
|
|
127
|
+
Math.round(valueGraph / maxGraph * graphHeight)
|
|
103
128
|
);
|
|
104
|
-
const columnHeight = this.GRAPH_HEIGHT - (1 - valueGraph / maxGraph) * this.GRAPH_HEIGHT;
|
|
105
129
|
if (columnHeight > 0) {
|
|
106
|
-
this.context.globalAlpha =
|
|
130
|
+
this.context.globalAlpha = 0.9;
|
|
107
131
|
this.context.fillStyle = this.gradient;
|
|
108
132
|
this.context.fillRect(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
133
|
+
graphX + graphWidth - pr,
|
|
134
|
+
graphY + (graphHeight - columnHeight),
|
|
135
|
+
pr,
|
|
112
136
|
columnHeight
|
|
113
137
|
);
|
|
114
138
|
}
|
|
139
|
+
this.context.globalAlpha = 1;
|
|
115
140
|
}
|
|
116
141
|
}
|
|
117
142
|
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,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,WAAW;AACxB,SAAA,O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
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();
|
|
@@ -71,45 +72,69 @@ class Panel {
|
|
|
71
72
|
this.context.globalAlpha = 0.9;
|
|
72
73
|
this.context.fillRect(this.GRAPH_X, this.GRAPH_Y, this.GRAPH_WIDTH, this.GRAPH_HEIGHT);
|
|
73
74
|
}
|
|
75
|
+
// Update only text portion
|
|
74
76
|
update(value, valueGraph, maxValue, maxGraph, decimals = 0) {
|
|
75
77
|
if (!this.context || !this.gradient)
|
|
76
78
|
return;
|
|
77
79
|
const min = Math.min(Infinity, value);
|
|
78
80
|
const max = Math.max(maxValue, value);
|
|
79
|
-
maxGraph = Math.max(maxGraph, valueGraph);
|
|
80
81
|
this.context.globalAlpha = 1;
|
|
81
82
|
this.context.fillStyle = this.bg;
|
|
82
83
|
this.context.fillRect(0, 0, this.WIDTH, this.GRAPH_Y);
|
|
83
84
|
this.context.fillStyle = this.fg;
|
|
84
85
|
this.context.fillText(
|
|
85
|
-
`${value.toFixed(decimals)} ${this.name} (${min.toFixed(decimals)}-${parseFloat(
|
|
86
|
-
max.toFixed(decimals)
|
|
87
|
-
)})`,
|
|
86
|
+
`${value.toFixed(decimals)} ${this.name} (${min.toFixed(decimals)}-${parseFloat(max.toFixed(decimals))})`,
|
|
88
87
|
this.TEXT_X,
|
|
89
88
|
this.TEXT_Y
|
|
90
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);
|
|
91
105
|
this.context.drawImage(
|
|
92
106
|
this.canvas,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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)
|
|
101
126
|
);
|
|
102
|
-
const columnHeight = this.GRAPH_HEIGHT - (1 - valueGraph / maxGraph) * this.GRAPH_HEIGHT;
|
|
103
127
|
if (columnHeight > 0) {
|
|
104
|
-
this.context.globalAlpha =
|
|
128
|
+
this.context.globalAlpha = 0.9;
|
|
105
129
|
this.context.fillStyle = this.gradient;
|
|
106
130
|
this.context.fillRect(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
131
|
+
graphX + graphWidth - pr,
|
|
132
|
+
graphY + (graphHeight - columnHeight),
|
|
133
|
+
pr,
|
|
110
134
|
columnHeight
|
|
111
135
|
);
|
|
112
136
|
}
|
|
137
|
+
this.context.globalAlpha = 1;
|
|
113
138
|
}
|
|
114
139
|
}
|
|
115
140
|
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,WAAW;AACxB,SAAA,OAAO,MAAM,UAAU;AAE5B,SAAK,UAAU,KAAK,OAAO,WAAW,IAAI;
|
|
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,KAA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;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,22 +52,28 @@ 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;
|
|
62
64
|
private gpuPanelCompute;
|
|
65
|
+
private averageFps;
|
|
63
66
|
private averageCpu;
|
|
64
67
|
private averageGpu;
|
|
65
68
|
private averageGpuCompute;
|
|
69
|
+
private updateCounter;
|
|
70
|
+
private prevGraphTime;
|
|
71
|
+
private lastMin;
|
|
72
|
+
private lastMax;
|
|
73
|
+
private lastValue;
|
|
74
|
+
private prevTextTime;
|
|
66
75
|
static Panel: typeof Panel;
|
|
67
|
-
constructor({ trackGPU, logsPerSecond, samplesLog, samplesGraph, precision, minimal, horizontal, mode }?: StatsOptions);
|
|
76
|
+
constructor({ trackGPU, logsPerSecond, graphsPerSecond, samplesLog, samplesGraph, precision, minimal, horizontal, mode }?: StatsOptions);
|
|
68
77
|
private initializeDOM;
|
|
69
78
|
private setupEventListeners;
|
|
70
79
|
private handleClick;
|
|
@@ -79,24 +88,27 @@ declare class Stats {
|
|
|
79
88
|
end(): void;
|
|
80
89
|
update(): void;
|
|
81
90
|
private processWebGPUTimestamps;
|
|
82
|
-
private updateAverages;
|
|
83
91
|
private resetCounters;
|
|
84
92
|
resizePanel(panel: Panel, offset: number): void;
|
|
85
93
|
addPanel(panel: Panel, offset: number): Panel;
|
|
86
94
|
showPanel(id: number): void;
|
|
87
95
|
processGpuQueries(): void;
|
|
88
96
|
endInternal(): number;
|
|
89
|
-
|
|
90
|
-
logs: any;
|
|
91
|
-
graph: any;
|
|
92
|
-
}): void;
|
|
97
|
+
private updatePanelComponents;
|
|
93
98
|
beginProfiling(marker: string): void;
|
|
94
99
|
endProfiling(startMarker: string | PerformanceMeasureOptions | undefined, endMarker: string | undefined, measureName: string): void;
|
|
95
100
|
updatePanel(panel: {
|
|
96
101
|
update: any;
|
|
102
|
+
updateGraph: any;
|
|
103
|
+
name: string;
|
|
97
104
|
} | null, averageArray: {
|
|
98
105
|
logs: number[];
|
|
99
106
|
graph: number[];
|
|
107
|
+
}, precision?: number): void;
|
|
108
|
+
private updateAverages;
|
|
109
|
+
addToAverage(value: number, averageArray: {
|
|
110
|
+
logs: any;
|
|
111
|
+
graph: any;
|
|
100
112
|
}): void;
|
|
101
113
|
get domElement(): HTMLDivElement;
|
|
102
114
|
patchThreeRenderer(renderer: any): void;
|
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,30 +53,40 @@ 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;
|
|
65
67
|
private gpuPanel: Panel | null = null;
|
|
66
68
|
private gpuPanelCompute: Panel | null = null;
|
|
67
69
|
|
|
70
|
+
private averageFps: AverageData = { logs: [], graph: [] };
|
|
68
71
|
private averageCpu: AverageData = { logs: [], graph: [] };
|
|
69
72
|
private averageGpu: AverageData = { logs: [], graph: [] };
|
|
70
73
|
private averageGpuCompute: AverageData = { logs: [], graph: [] };
|
|
71
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
|
+
|
|
72
83
|
static Panel = Panel;
|
|
73
84
|
|
|
74
85
|
constructor({
|
|
75
86
|
trackGPU = false,
|
|
76
|
-
logsPerSecond =
|
|
77
|
-
|
|
87
|
+
logsPerSecond = 4,
|
|
88
|
+
graphsPerSecond = 30,
|
|
89
|
+
samplesLog = 40,
|
|
78
90
|
samplesGraph = 10,
|
|
79
91
|
precision = 2,
|
|
80
92
|
minimal = false,
|
|
@@ -89,6 +101,9 @@ class Stats {
|
|
|
89
101
|
this.samplesGraph = samplesGraph;
|
|
90
102
|
this.precision = precision;
|
|
91
103
|
this.logsPerSecond = logsPerSecond;
|
|
104
|
+
this.graphsPerSecond = graphsPerSecond;
|
|
105
|
+
const prevGraphTime = performance.now();
|
|
106
|
+
this.prevGraphTime = prevGraphTime
|
|
92
107
|
|
|
93
108
|
// Initialize DOM
|
|
94
109
|
this.dom = document.createElement('div');
|
|
@@ -97,6 +112,8 @@ class Stats {
|
|
|
97
112
|
// Initialize timing
|
|
98
113
|
this.beginTime = performance.now();
|
|
99
114
|
this.prevTime = this.beginTime;
|
|
115
|
+
this.prevTextTime = this.beginTime;
|
|
116
|
+
|
|
100
117
|
this.prevCpuTime = this.beginTime;
|
|
101
118
|
|
|
102
119
|
// Create panels
|
|
@@ -106,6 +123,7 @@ class Stats {
|
|
|
106
123
|
this.setupEventListeners();
|
|
107
124
|
}
|
|
108
125
|
|
|
126
|
+
|
|
109
127
|
private initializeDOM(): void {
|
|
110
128
|
this.dom.style.cssText = `
|
|
111
129
|
position: fixed;
|
|
@@ -246,39 +264,35 @@ class Stats {
|
|
|
246
264
|
}
|
|
247
265
|
|
|
248
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
|
+
|
|
249
274
|
if (!this.info) {
|
|
250
275
|
this.processGpuQueries();
|
|
251
276
|
} else {
|
|
252
277
|
this.processWebGPUTimestamps();
|
|
253
278
|
}
|
|
254
279
|
|
|
255
|
-
this.
|
|
256
|
-
this.updateAverages();
|
|
280
|
+
this.updateAverages()
|
|
257
281
|
this.resetCounters();
|
|
258
282
|
}
|
|
259
283
|
|
|
260
284
|
private processWebGPUTimestamps(): void {
|
|
261
285
|
this.totalGpuDuration = this.info!.render.timestamp;
|
|
262
286
|
this.totalGpuDurationCompute = this.info!.compute.timestamp;
|
|
263
|
-
this.addToAverage(this.totalGpuDurationCompute, this.averageGpuCompute);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
private updateAverages(): void {
|
|
267
|
-
this.addToAverage(this.totalCpuDuration, this.averageCpu);
|
|
268
|
-
this.addToAverage(this.totalGpuDuration, this.averageGpu);
|
|
269
287
|
}
|
|
270
288
|
|
|
271
289
|
private resetCounters(): void {
|
|
272
290
|
this.renderCount = 0;
|
|
273
|
-
if (this.totalCpuDuration === 0) {
|
|
274
|
-
this.beginProfiling('cpu-started');
|
|
275
|
-
}
|
|
276
291
|
this.totalCpuDuration = 0;
|
|
277
|
-
this.
|
|
292
|
+
this.beginProfiling('cpu-started');
|
|
278
293
|
this.beginTime = this.endInternal();
|
|
279
294
|
}
|
|
280
295
|
|
|
281
|
-
|
|
282
296
|
resizePanel(panel: Panel, offset: number) {
|
|
283
297
|
|
|
284
298
|
panel.canvas.style.position = 'absolute';
|
|
@@ -353,52 +367,95 @@ class Stats {
|
|
|
353
367
|
}
|
|
354
368
|
|
|
355
369
|
endInternal() {
|
|
370
|
+
const currentTime = performance.now();
|
|
356
371
|
|
|
357
|
-
this.
|
|
358
|
-
const time = (performance || Date).now();
|
|
359
|
-
|
|
360
|
-
if (time >= this.prevCpuTime + 1000 / this.logsPerSecond) {
|
|
361
|
-
this.updatePanel(this.msPanel, this.averageCpu);
|
|
362
|
-
this.updatePanel(this.gpuPanel, this.averageGpu);
|
|
363
|
-
|
|
364
|
-
if (this.gpuPanelCompute) {
|
|
365
|
-
this.updatePanel(this.gpuPanelCompute, this.averageGpuCompute);
|
|
366
|
-
}
|
|
372
|
+
this.frameTimes.push(currentTime);
|
|
367
373
|
|
|
368
|
-
|
|
374
|
+
// Remove frames older than 1 second
|
|
375
|
+
while (this.frameTimes.length > 0 && this.frameTimes[0] <= currentTime - 1000) {
|
|
376
|
+
this.frameTimes.shift();
|
|
369
377
|
}
|
|
370
378
|
|
|
371
|
-
|
|
379
|
+
// Calculate FPS based on frames in the last second
|
|
380
|
+
const fps = Math.round(this.frameTimes.length);
|
|
372
381
|
|
|
373
|
-
|
|
382
|
+
this.addToAverage(fps, this.averageFps);
|
|
374
383
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
this.prevTime = time;
|
|
378
|
-
this.frames = 0;
|
|
384
|
+
const shouldUpdateText = currentTime >= this.prevTextTime + 1000 / this.logsPerSecond;
|
|
385
|
+
const shouldUpdateGraph = currentTime >= this.prevGraphTime + 1000 / this.graphsPerSecond;
|
|
379
386
|
|
|
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);
|
|
380
394
|
}
|
|
381
395
|
|
|
382
|
-
|
|
396
|
+
if (shouldUpdateText) {
|
|
397
|
+
this.prevTextTime = currentTime;
|
|
398
|
+
}
|
|
399
|
+
if (shouldUpdateGraph) {
|
|
400
|
+
this.prevGraphTime = currentTime;
|
|
401
|
+
}
|
|
383
402
|
|
|
403
|
+
return currentTime;
|
|
384
404
|
}
|
|
385
405
|
|
|
386
|
-
|
|
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
|
+
}
|
|
387
421
|
|
|
388
|
-
averageArray.logs.
|
|
389
|
-
|
|
422
|
+
const currentValue = averageArray.logs[averageArray.logs.length - 1];
|
|
423
|
+
const recentMax = Math.max(...averageArray.logs.slice(-30));
|
|
390
424
|
|
|
391
|
-
|
|
425
|
+
this.lastMin[panel.name] = Math.min(this.lastMin[panel.name], currentValue);
|
|
426
|
+
this.lastMax[panel.name] = Math.max(this.lastMax[panel.name], currentValue);
|
|
392
427
|
|
|
393
|
-
|
|
428
|
+
// Smooth the display value
|
|
429
|
+
this.lastValue[panel.name] = this.lastValue[panel.name] * 0.7 + currentValue * 0.3;
|
|
394
430
|
|
|
395
|
-
averageArray.graph.
|
|
396
|
-
|
|
431
|
+
const graphMax = Math.max(recentMax, ...averageArray.graph.slice(-this.samplesGraph));
|
|
432
|
+
|
|
433
|
+
this.updateCounter++;
|
|
397
434
|
|
|
398
|
-
|
|
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;
|
|
439
|
+
}
|
|
399
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
|
+
);
|
|
400
450
|
}
|
|
401
451
|
|
|
452
|
+
// Update graph if it's time
|
|
453
|
+
if (shouldUpdateGraph) {
|
|
454
|
+
panel.updateGraph(
|
|
455
|
+
currentValue,
|
|
456
|
+
graphMax
|
|
457
|
+
);
|
|
458
|
+
}
|
|
402
459
|
}
|
|
403
460
|
|
|
404
461
|
beginProfiling(marker: string) {
|
|
@@ -425,39 +482,88 @@ class Stats {
|
|
|
425
482
|
|
|
426
483
|
}
|
|
427
484
|
|
|
428
|
-
updatePanel(panel: { update: any; } | null, averageArray: { logs: number[], graph: number[] }) {
|
|
429
|
-
|
|
430
|
-
if (averageArray.logs.length > 0) {
|
|
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;
|
|
431
487
|
|
|
432
|
-
|
|
433
|
-
let max = 0.01;
|
|
488
|
+
const currentTime = performance.now();
|
|
434
489
|
|
|
435
|
-
|
|
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
|
+
}
|
|
436
496
|
|
|
437
|
-
|
|
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));
|
|
438
500
|
|
|
439
|
-
|
|
440
|
-
|
|
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
|
-
|
|
505
|
+
// Smooth the display value
|
|
506
|
+
this.lastValue[panel.name] = this.lastValue[panel.name] * 0.7 + currentValue * 0.3;
|
|
444
507
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
for (let i = 0; i < averageArray.graph.length; i++) {
|
|
508
|
+
// Calculate graph scaling value
|
|
509
|
+
const graphMax = Math.max(recentMax, ...averageArray.graph.slice(-this.samplesGraph));
|
|
448
510
|
|
|
449
|
-
|
|
511
|
+
this.updateCounter++;
|
|
450
512
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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
|
+
}
|
|
454
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
|
+
);
|
|
455
529
|
}
|
|
456
530
|
|
|
457
|
-
if (
|
|
458
|
-
|
|
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;
|
|
459
538
|
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
460
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
|
+
// }
|
|
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);
|
|
461
567
|
}
|
|
462
568
|
}
|
|
463
569
|
|