refacotr interval to be self documenting
This commit is contained in:
1 parent
5b395b96cd
commit
39779b9dd5
1 file changed
+3
-2
@@ -56,12 +56,13 @@ class DiagnosticController {
|
|||||||
async getCPUUsage() {
|
async getCPUUsage() {
|
||||||
try {
|
try {
|
||||||
const startUsage = process.cpuUsage();
|
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 endUsage = process.cpuUsage(startUsage);
|
||||||
const cpuUsage = {
|
const cpuUsage = {
|
||||||
userUsageMs: endUsage.user / 1000,
|
userUsageMs: endUsage.user / 1000,
|
||||||
systemUsageMs: endUsage.system / 1000,
|
systemUsageMs: endUsage.system / 1000,
|
||||||
usagePercentage: ((endUsage.user + endUsage.system) / 1000 / 1000) * 100,
|
usagePercentage: ((endUsage.user + endUsage.system) / 1000 / timingPeriod) * 100,
|
||||||
};
|
};
|
||||||
return cpuUsage;
|
return cpuUsage;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in new issue
Block a user