Merge pull request #2620 from bluewave-labs/feat/diagnostics

Feat/diagnostics
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-07-15 15:21:15 -07:00
commit c54feb9306
3 files changed
+31 -16

No files matched your search

+3 -2
View File
@@ -56,12 +56,13 @@ class DiagnosticController {
async getCPUUsage() {
try {
const startUsage = process.cpuUsage();
await new Promise((resolve) => setTimeout(resolve, 1000));
const timingPeriod = 1000; // measured in ms
await new Promise((resolve) => setTimeout(resolve, timingPeriod));
const endUsage = process.cpuUsage(startUsage);
const cpuUsage = {
userUsageMs: endUsage.user / 1000,
systemUsageMs: endUsage.system / 1000,
usagePercentage: ((endUsage.user + endUsage.system) / 1000 / 1000) * 100,
usagePercentage: ((endUsage.user + endUsage.system) / 1000 / timingPeriod) * 100,
};
return cpuUsage;
} catch (error) {