ZennyKenny commited on
Commit
755dfbe
·
verified ·
1 Parent(s): ffd7c1e

use real data

Browse files
Files changed (1) hide show
  1. index.html +12 -11
index.html CHANGED
@@ -21,13 +21,13 @@
21
  labels: labels,
22
  datasets: [
23
  {
24
- label: 'CPU Time (ms)',
25
  data: cpuData,
26
  borderColor: 'red',
27
  fill: false
28
  },
29
  {
30
- label: 'GPU Load',
31
  data: gpuData,
32
  borderColor: 'blue',
33
  fill: false
@@ -55,26 +55,27 @@
55
  });
56
  }
57
 
58
- function getCPUInfo() {
59
- const start = performance.now();
60
- let sum = 0;
61
- for (let i = 0; i < 1e7; i++) { sum += Math.sqrt(i); }
62
- const end = performance.now();
63
- return end - start;
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
- return Math.random() * 100; // Mock GPU load percentage
 
71
  }
72
 
73
  function updatePerformanceData() {
74
  const elapsed = ((performance.now() - startTime) / 1000).toFixed(1);
75
  labels.push(elapsed);
76
- cpuData.push(getCPUInfo().toFixed(2));
77
- gpuData.push(getGPUInfo().toFixed(2));
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();