Skip to content
This repository has been archived by the owner on Sep 30, 2018. It is now read-only.

Commit

Permalink
[droid] fixed cpu usage got NaN when no cpu stats changed
Browse files Browse the repository at this point in the history
  • Loading branch information
huceke committed Aug 4, 2012
1 parent 541abf3 commit 7a7047d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xbmc/utils/CPUInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,10 @@ bool CCPUInfo::readProcStat(unsigned long long& user, unsigned long long& nice,
coreIO -= iter->second.m_io;

double total = (double)(coreUser + coreNice + coreSystem + coreIdle + coreIO);
iter->second.m_fPct = ((double)(coreUser + coreNice + coreSystem) * 100.0) / total;
if(total == 0.0f)
iter->second.m_fPct = 0.0f;
else
iter->second.m_fPct = ((double)(coreUser + coreNice + coreSystem) * 100.0) / total;

iter->second.m_user += coreUser;
iter->second.m_nice += coreNice;
Expand Down

0 comments on commit 7a7047d

Please sign in to comment.