MCPcopy Create free account
hub / github.com/Tencent/Hardcoder / run

Method run

libapp2sys/src/main/cpp/procutil.h:179–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177 }
178
179 int run() {
180 m_pStatReader->update();
181 int32_t j = m_pStatReader->getValue(STAT_USER_JIFFIES_INDEX) + m_pStatReader->getValue(STAT_SYS_JIFFIES_INDEX);
182 int cpuId = m_pStatReader->getValue(38);
183
184 if (j < 0 || cpuId < 0 || cpuId >= CPU_COUNT) {
185 return -1;
186 }
187
188 m_ppCpuFfreqReader[cpuId]->update();
189 int64_t freqHz = m_ppCpuFfreqReader[cpuId]->getValue(0);
190 m_sumCpuLoad += (freqHz * (j - m_lastJiffies));
191
192// uint64_t now = getMillisecond();
193// uint32_t diff = lastRun ? now - lastRun : 0 ;
194// lastRun = now;
195// pdbg("run diff:%d core:%d freq:%lld j:%d last:%d load:%lld ", diff, cpuId, freqHz , j , m_lastJiffies , (freqHz * (j - m_lastJiffies)));
196
197 m_lastJiffies = j;
198 return 0;
199 }
200
201public:
202 int start(uint32_t linuxTid, uint64_t sampleRateMS = 15) {

Callers 1

monitorThreadMethod · 0.45

Calls 2

getValueMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected