mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 09:58:03 +02:00
Memory: improve performance by not querying WMI (Windows)
This commit is contained in:
+2
-2
@@ -434,13 +434,13 @@ elseif(WIN32)
|
||||
src/detection/host/host_windows.cpp
|
||||
src/detection/localip/localip_windows.c
|
||||
src/detection/media/media_nosupport.c
|
||||
src/detection/memory/memory_windows.cpp
|
||||
src/detection/memory/memory_windows.c
|
||||
src/detection/opengl/opengl_windows.c
|
||||
src/detection/os/os_windows.cpp
|
||||
src/detection/packages/packages_windows.c
|
||||
src/detection/poweradapter/poweradapter_nosupport.c
|
||||
src/detection/processes/processes_windows.cpp
|
||||
src/detection/swap/swap_windows.cpp
|
||||
src/detection/swap/swap_windows.c
|
||||
src/detection/terminalfont/terminalfont_windows.c
|
||||
src/detection/terminalshell/terminalshell_windows.cpp
|
||||
src/detection/uptime/uptime_windows.c
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "memory.h"
|
||||
|
||||
void ffDetectMemoryImpl(FFMemoryStorage* ram)
|
||||
{
|
||||
MEMORYSTATUSEX statex = {
|
||||
.dwLength = sizeof(statex),
|
||||
};
|
||||
GlobalMemoryStatusEx(&statex);
|
||||
ram->bytesTotal = statex.ullTotalPhys;
|
||||
ram->bytesUsed = statex.ullTotalPhys - statex.ullAvailPhys;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
extern "C" {
|
||||
#include "memory.h"
|
||||
}
|
||||
#include "util/windows/wmi.hpp"
|
||||
|
||||
extern "C"
|
||||
void ffDetectMemoryImpl(FFMemoryStorage* ram)
|
||||
{
|
||||
FFWmiQuery query(L"SELECT TotalVisibleMemorySize, FreePhysicalMemory FROM Win32_OperatingSystem", &ram->error);
|
||||
if(!query)
|
||||
return;
|
||||
|
||||
if(FFWmiRecord record = query.next())
|
||||
{
|
||||
//KB
|
||||
record.getUnsigned(L"TotalVisibleMemorySize", &ram->bytesTotal);
|
||||
uint64_t bytesFree;
|
||||
record.getUnsigned(L"FreePhysicalMemory", &bytesFree);
|
||||
ram->bytesUsed = ram->bytesTotal - bytesFree;
|
||||
ram->bytesTotal *= 1024;
|
||||
ram->bytesUsed *= 1024;
|
||||
}
|
||||
else
|
||||
ffStrbufInitS(&ram->error, "No Wmi result returned");
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "swap.h"
|
||||
|
||||
void ffDetectSwapImpl(FFMemoryStorage* swap)
|
||||
{
|
||||
MEMORYSTATUSEX statex = {
|
||||
.dwLength = sizeof(statex),
|
||||
};
|
||||
GlobalMemoryStatusEx(&statex);
|
||||
swap->bytesTotal = statex.ullTotalPageFile;
|
||||
swap->bytesUsed = statex.ullTotalPageFile - statex.ullAvailPageFile;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
extern "C" {
|
||||
#include "swap.h"
|
||||
}
|
||||
#include "util/windows/wmi.hpp"
|
||||
|
||||
extern "C"
|
||||
void ffDetectSwapImpl(FFMemoryStorage* swap)
|
||||
{
|
||||
FFWmiQuery query(L"SELECT AllocatedBaseSize, CurrentUsage FROM Win32_PageFileUsage", &swap->error);
|
||||
if(!query)
|
||||
return;
|
||||
|
||||
if(FFWmiRecord record = query.next())
|
||||
{
|
||||
//MB
|
||||
record.getUnsigned(L"AllocatedBaseSize", &swap->bytesTotal);
|
||||
record.getUnsigned(L"CurrentUsage", &swap->bytesUsed);
|
||||
swap->bytesTotal *= 1024 * 1024;
|
||||
swap->bytesUsed *= 1024 * 1024;
|
||||
}
|
||||
else
|
||||
ffStrbufInitS(&swap->error, "No Wmi result returned");
|
||||
}
|
||||
Reference in New Issue
Block a user