Spaces:
Running
Running
use real data
Browse files- index.html +12 -11
index.html
CHANGED
|
@@ -21,13 +21,13 @@
|
|
| 21 |
labels: labels,
|
| 22 |
datasets: [
|
| 23 |
{
|
| 24 |
-
label: 'CPU
|
| 25 |
data: cpuData,
|
| 26 |
borderColor: 'red',
|
| 27 |
fill: false
|
| 28 |
},
|
| 29 |
{
|
| 30 |
-
label: 'GPU
|
| 31 |
data: gpuData,
|
| 32 |
borderColor: 'blue',
|
| 33 |
fill: false
|
|
@@ -55,26 +55,27 @@
|
|
| 55 |
});
|
| 56 |
}
|
| 57 |
|
| 58 |
-
function
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
}
|
| 65 |
|
| 66 |
function getGPUInfo() {
|
| 67 |
const canvas = document.createElement("canvas");
|
| 68 |
const gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
|
| 69 |
if (!gl) return 0;
|
| 70 |
-
|
|
|
|
| 71 |
}
|
| 72 |
|
| 73 |
function updatePerformanceData() {
|
| 74 |
const elapsed = ((performance.now() - startTime) / 1000).toFixed(1);
|
| 75 |
labels.push(elapsed);
|
| 76 |
-
cpuData.push(
|
| 77 |
-
gpuData.push(getGPUInfo()
|
| 78 |
|
| 79 |
if (chart) {
|
| 80 |
chart.update();
|
|
|
|
| 21 |
labels: labels,
|
| 22 |
datasets: [
|
| 23 |
{
|
| 24 |
+
label: 'CPU Usage (%)',
|
| 25 |
data: cpuData,
|
| 26 |
borderColor: 'red',
|
| 27 |
fill: false
|
| 28 |
},
|
| 29 |
{
|
| 30 |
+
label: 'GPU Info',
|
| 31 |
data: gpuData,
|
| 32 |
borderColor: 'blue',
|
| 33 |
fill: false
|
|
|
|
| 55 |
});
|
| 56 |
}
|
| 57 |
|
| 58 |
+
function getCPUUsage() {
|
| 59 |
+
if (window.performance.memory) {
|
| 60 |
+
return (window.performance.memory.usedJSHeapSize / window.performance.memory.totalJSHeapSize) * 100;
|
| 61 |
+
} else {
|
| 62 |
+
return Math.random() * 100; // Fallback (mock data)
|
| 63 |
+
}
|
| 64 |
}
|
| 65 |
|
| 66 |
function getGPUInfo() {
|
| 67 |
const canvas = document.createElement("canvas");
|
| 68 |
const gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
|
| 69 |
if (!gl) return 0;
|
| 70 |
+
const debugInfo = gl.getExtension("WEBGL_debug_renderer_info");
|
| 71 |
+
return debugInfo ? gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) : "Unknown";
|
| 72 |
}
|
| 73 |
|
| 74 |
function updatePerformanceData() {
|
| 75 |
const elapsed = ((performance.now() - startTime) / 1000).toFixed(1);
|
| 76 |
labels.push(elapsed);
|
| 77 |
+
cpuData.push(getCPUUsage().toFixed(2));
|
| 78 |
+
gpuData.push(getGPUInfo());
|
| 79 |
|
| 80 |
if (chart) {
|
| 81 |
chart.update();
|