mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Minor optimizations for memory measures
This commit is contained in:
parent
adeb73478b
commit
cbee39e5d5
@ -27,6 +27,10 @@
|
|||||||
CMeasureMemory::CMeasureMemory(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
|
CMeasureMemory::CMeasureMemory(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
|
||||||
m_Total(false)
|
m_Total(false)
|
||||||
{
|
{
|
||||||
|
MEMORYSTATUSEX stat;
|
||||||
|
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
||||||
|
GlobalMemoryStatusEx(&stat);
|
||||||
|
m_MaxValue = (double)(__int64)(stat.ullTotalPageFile + stat.ullTotalPhys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -43,15 +47,12 @@ CMeasureMemory::~CMeasureMemory()
|
|||||||
*/
|
*/
|
||||||
void CMeasureMemory::UpdateValue()
|
void CMeasureMemory::UpdateValue()
|
||||||
{
|
{
|
||||||
|
if (!m_Total)
|
||||||
|
{
|
||||||
MEMORYSTATUSEX stat;
|
MEMORYSTATUSEX stat;
|
||||||
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
||||||
GlobalMemoryStatusEx(&stat);
|
GlobalMemoryStatusEx(&stat);
|
||||||
if (m_Total)
|
|
||||||
{
|
|
||||||
m_Value = (double)(__int64)(stat.ullTotalPageFile + stat.ullTotalPhys);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Value = (double)(__int64)(stat.ullTotalPageFile + stat.ullTotalPhys - stat.ullAvailPageFile - stat.ullAvailPhys);
|
m_Value = (double)(__int64)(stat.ullTotalPageFile + stat.ullTotalPhys - stat.ullAvailPageFile - stat.ullAvailPhys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,13 +63,13 @@ void CMeasureMemory::UpdateValue()
|
|||||||
*/
|
*/
|
||||||
void CMeasureMemory::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
void CMeasureMemory::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
||||||
{
|
{
|
||||||
|
double oldMaxValue = m_MaxValue;
|
||||||
CMeasure::ReadOptions(parser, section);
|
CMeasure::ReadOptions(parser, section);
|
||||||
|
m_MaxValue = oldMaxValue;
|
||||||
|
|
||||||
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
|
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
|
||||||
|
if (m_Total)
|
||||||
MEMORYSTATUSEX stat;
|
{
|
||||||
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
m_Value = m_MaxValue;
|
||||||
GlobalMemoryStatusEx(&stat);
|
}
|
||||||
m_MaxValue = (double)(__int64)(stat.ullTotalPageFile + stat.ullTotalPhys);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
CMeasurePhysicalMemory::CMeasurePhysicalMemory(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
|
CMeasurePhysicalMemory::CMeasurePhysicalMemory(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
|
||||||
m_Total(false)
|
m_Total(false)
|
||||||
{
|
{
|
||||||
|
MEMORYSTATUSEX stat;
|
||||||
|
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
||||||
|
GlobalMemoryStatusEx(&stat);
|
||||||
|
m_MaxValue = (double)(__int64)stat.ullTotalPhys;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -43,15 +47,12 @@ CMeasurePhysicalMemory::~CMeasurePhysicalMemory()
|
|||||||
*/
|
*/
|
||||||
void CMeasurePhysicalMemory::UpdateValue()
|
void CMeasurePhysicalMemory::UpdateValue()
|
||||||
{
|
{
|
||||||
|
if (!m_Total)
|
||||||
|
{
|
||||||
MEMORYSTATUSEX stat;
|
MEMORYSTATUSEX stat;
|
||||||
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
||||||
GlobalMemoryStatusEx(&stat);
|
GlobalMemoryStatusEx(&stat);
|
||||||
if (m_Total)
|
|
||||||
{
|
|
||||||
m_Value = (double)(__int64)stat.ullTotalPhys;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Value = (double)(__int64)(stat.ullTotalPhys - stat.ullAvailPhys);
|
m_Value = (double)(__int64)(stat.ullTotalPhys - stat.ullAvailPhys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,13 +63,14 @@ void CMeasurePhysicalMemory::UpdateValue()
|
|||||||
*/
|
*/
|
||||||
void CMeasurePhysicalMemory::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
void CMeasurePhysicalMemory::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
||||||
{
|
{
|
||||||
|
double oldMaxValue = m_MaxValue;
|
||||||
CMeasure::ReadOptions(parser, section);
|
CMeasure::ReadOptions(parser, section);
|
||||||
|
m_MaxValue = oldMaxValue;
|
||||||
|
|
||||||
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
|
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
|
||||||
|
if (m_Total)
|
||||||
MEMORYSTATUSEX stat;
|
{
|
||||||
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
m_Value = m_MaxValue;
|
||||||
GlobalMemoryStatusEx(&stat);
|
}
|
||||||
m_MaxValue = (double)(__int64)stat.ullTotalPhys;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
CMeasureVirtualMemory::CMeasureVirtualMemory(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
|
CMeasureVirtualMemory::CMeasureVirtualMemory(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
|
||||||
m_Total(false)
|
m_Total(false)
|
||||||
{
|
{
|
||||||
|
MEMORYSTATUSEX stat;
|
||||||
|
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
||||||
|
GlobalMemoryStatusEx(&stat);
|
||||||
|
m_MaxValue = (double)(__int64)stat.ullTotalPageFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -43,15 +47,12 @@ CMeasureVirtualMemory::~CMeasureVirtualMemory()
|
|||||||
*/
|
*/
|
||||||
void CMeasureVirtualMemory::UpdateValue()
|
void CMeasureVirtualMemory::UpdateValue()
|
||||||
{
|
{
|
||||||
|
if (!m_Total)
|
||||||
|
{
|
||||||
MEMORYSTATUSEX stat;
|
MEMORYSTATUSEX stat;
|
||||||
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
||||||
GlobalMemoryStatusEx(&stat);
|
GlobalMemoryStatusEx(&stat);
|
||||||
if (m_Total)
|
|
||||||
{
|
|
||||||
m_Value = (double)(__int64)stat.ullTotalPageFile;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Value = (double)(__int64)(stat.ullTotalPageFile - stat.ullAvailPageFile);
|
m_Value = (double)(__int64)(stat.ullTotalPageFile - stat.ullAvailPageFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,13 +63,14 @@ void CMeasureVirtualMemory::UpdateValue()
|
|||||||
*/
|
*/
|
||||||
void CMeasureVirtualMemory::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
void CMeasureVirtualMemory::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
||||||
{
|
{
|
||||||
|
double oldMaxValue = m_MaxValue;
|
||||||
CMeasure::ReadOptions(parser, section);
|
CMeasure::ReadOptions(parser, section);
|
||||||
|
m_MaxValue = oldMaxValue;
|
||||||
|
|
||||||
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
|
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
|
||||||
|
if (m_Total)
|
||||||
MEMORYSTATUSEX stat;
|
{
|
||||||
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
m_Value = m_MaxValue;
|
||||||
GlobalMemoryStatusEx(&stat);
|
}
|
||||||
m_MaxValue = (double)(__int64)stat.ullTotalPageFile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user