|
@@ -0,0 +1,26 @@
|
|
|
|
|
+#include "sysinfowindowsimpl.h"
|
|
|
|
|
+
|
|
|
|
|
+SysInfoWindowsImpl::SysInfoWindowsImpl() : SysInfo() {}
|
|
|
|
|
+
|
|
|
|
|
+void SysInfoWindowsImpl::init() {}
|
|
|
|
|
+
|
|
|
|
|
+double SysInfoWindowsImpl::cpuLoadAverage() {
|
|
|
|
|
+ QVector<qulonglong> firstSample = mCpuLoadLastValues;
|
|
|
|
|
+ QVector<qulonglong> secondSample = cpuRawData();
|
|
|
|
|
+ mCpuLoadLastValues = secondSample;
|
|
|
|
|
+ qulonglong currentIdle = secondSample[0] - firstSample[0];
|
|
|
|
|
+ qulonglong currentKernel = secondSample[1] - firstSample[1];
|
|
|
|
|
+ qulonglong currentUser = secondSample[2] - firstSample[2];
|
|
|
|
|
+ qulonglong currentSystem = currentKernel + currentUser;
|
|
|
|
|
+ double percent = (currentSystem - currentIdle) * 100.0 / currentSystem;
|
|
|
|
|
+ return qBound(0.0, percent, 100.0);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+double SysInfoWindowsImpl::memoryUsed() {
|
|
|
|
|
+ MEMORYSTATUSEX memoryStatus;
|
|
|
|
|
+ memoryStatus.dwLength = sizeof(MEMORYSTATUSEX);
|
|
|
|
|
+ GlobalMemoryStatusEx(&memoryStatus);
|
|
|
|
|
+ qulonglong memoryPhysicalUsed =
|
|
|
|
|
+ memoryStatus.ullTotalPhys - memoryStatus.ullAvailPhys;
|
|
|
|
|
+ return (double)memoryPhysicalUsed / (double)memoryStatus.ullTotalPhys * 100.0;
|
|
|
|
|
+}
|