Disabled double update on initialization for measures

This commit is contained in:
Birunthan Mohanathas 2012-04-09 20:50:46 +03:00
parent 66a5579550
commit bb4bcbdce3
4 changed files with 9 additions and 34 deletions

View File

@ -65,7 +65,6 @@ ULONG CMeasureCPU::c_BufferSize = 0;
** **
*/ */
CMeasureCPU::CMeasureCPU(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name), CMeasureCPU::CMeasureCPU(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_FirstTime(true),
m_Processor(), m_Processor(),
m_OldTime() m_OldTime()
{ {
@ -99,24 +98,12 @@ void CMeasureCPU::ReadConfig(CConfigParser& parser, const WCHAR* section)
{ {
CMeasure::ReadConfig(parser, section); CMeasure::ReadConfig(parser, section);
int processor = parser.ReadInt(section, L"Processor", 0); m_Processor = parser.ReadInt(section, L"Processor", 0);
if (processor < 0 || processor > c_NumOfProcessors) if (m_Processor < 0 || m_Processor > c_NumOfProcessors)
{ {
LogWithArgs(LOG_WARNING, L"CPU: Processor=%i invalid in [%s]", processor, section); LogWithArgs(LOG_WARNING, L"CPU: Processor=%i invalid in [%s]", m_Processor, section);
m_Processor = 0;
processor = 0;
}
if (processor != m_Processor)
{
m_Processor = processor;
m_FirstTime = true;
}
if (m_FirstTime)
{
m_OldTime[0] = m_OldTime[1] = 0.0;
} }
} }
@ -222,20 +209,11 @@ bool CMeasureCPU::Update()
*/ */
void CMeasureCPU::CalcUsage(double idleTime, double systemTime) void CMeasureCPU::CalcUsage(double idleTime, double systemTime)
{ {
if (!m_FirstTime) // CurrentCpuUsage% = 100 - ((IdleTime / SystemTime) * 100)
{ double dbCpuUsage = 100.0 - ((idleTime - m_OldTime[0]) / (systemTime - m_OldTime[1])) * 100.0;
double dbCpuUsage;
// CurrentCpuUsage% = 100 - ((IdleTime / SystemTime) * 100) dbCpuUsage = min(dbCpuUsage, 100.0);
dbCpuUsage = 100.0 - ((idleTime - m_OldTime[0]) / (systemTime - m_OldTime[1])) * 100.0; m_Value = max(dbCpuUsage, 0.0);
dbCpuUsage = min(dbCpuUsage, 100.0);
m_Value = max(dbCpuUsage, 0.0);
}
else
{
m_FirstTime = false;
}
// store new CPU's idle and system time // store new CPU's idle and system time
m_OldTime[0] = idleTime; m_OldTime[0] = idleTime;

View File

@ -39,8 +39,6 @@ protected:
private: private:
void CalcUsage(double idleTime, double systemTime); void CalcUsage(double idleTime, double systemTime);
bool m_FirstTime;
int m_Processor; int m_Processor;
double m_OldTime[2]; double m_OldTime[2];

View File

@ -2798,7 +2798,7 @@ void CMeterWindow::Update(bool nodraw)
{ {
++m_UpdateCounter; ++m_UpdateCounter;
if (!m_Measures.empty()) if (!nodraw && !m_Measures.empty())
{ {
// Pre-updates // Pre-updates
if (m_HasNetMeasures) if (m_HasNetMeasures)

View File

@ -91,7 +91,6 @@
<DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4018;4090;4114;4351;4786;4800;4996</DisableSpecificWarnings> <DisableSpecificWarnings>4018;4090;4114;4351;4786;4800;4996</DisableSpecificWarnings>
<AdditionalIncludeDirectories>.\sha2;.\taglib;.\taglib\toolkit;.\taglib\mpeg\id3v2\frames;.\taglib\ogg;.\taglib\asf;.\taglib\mp4;.\taglib\ogg\vorbis;.\taglib\ogg\flac;.\taglib\ogg\speex;.\taglib\riff;.\taglib\riff\wav;.\taglib\riff\aiff;.\taglib\flac;.\taglib\mpeg;.\taglib\mpeg\id3v1;.\taglib\mpeg\id3v2;.\taglib\mpc;.\taglib\ape;.\taglib\trueaudio;.\taglib\wavpack;.\SDKs\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.\sha2;.\taglib;.\taglib\toolkit;.\taglib\mpeg\id3v2\frames;.\taglib\ogg;.\taglib\asf;.\taglib\mp4;.\taglib\ogg\vorbis;.\taglib\ogg\flac;.\taglib\ogg\speex;.\taglib\riff;.\taglib\riff\wav;.\taglib\riff\aiff;.\taglib\flac;.\taglib\mpeg;.\taglib\mpeg\id3v1;.\taglib\mpeg\id3v2;.\taglib\mpc;.\taglib\ape;.\taglib\trueaudio;.\taglib\wavpack;.\SDKs\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
</ClCompile> </ClCompile>
<ResourceCompile> <ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>