コード例 #1
0
 private CpuModel saveModel(CpuModel currentCpuModel, CpuModel preCpuModel) {
   CpuModel model = new CpuModel();
   model.setUserTime(currentCpuModel.getUserTime() - preCpuModel.getUserTime());
   model.setNiceTime(currentCpuModel.getNiceTime() - preCpuModel.getNiceTime());
   model.setSysTime(currentCpuModel.getSysTime() - preCpuModel.getSysTime());
   model.setIdleTime(currentCpuModel.getIdleTime() - preCpuModel.getIdleTime());
   model.setIowaitTime(currentCpuModel.getIowaitTime() - preCpuModel.getIowaitTime());
   model.setIrqTime(currentCpuModel.getIrqTime() - preCpuModel.getIrqTime());
   model.setSoftirqTime(currentCpuModel.getSoftirqTime() - preCpuModel.getSoftirqTime());
   model.setStealstolenTime(
       currentCpuModel.getStealstolenTime() - preCpuModel.getStealstolenTime());
   model.setGuestTime(currentCpuModel.getGuestTime() - preCpuModel.getGuestTime());
   model.setTotalCpuTime(currentCpuModel.getTotalCpuTime() - preCpuModel.getTotalCpuTime());
   return model;
 }
コード例 #2
0
 /**
  * 功能描述: 计算总的CPU时间
  *
  * @param cpuModel
  * @return
  * @see [相关类/方法](可选)
  * @since [产品/模块版本](可选)
  */
 private long sumTotalCpuTime(CpuModel cpuModel) {
   return cpuModel.getUserTime()
       + cpuModel.getNiceTime()
       + cpuModel.getSysTime()
       + cpuModel.getIdleTime()
       + cpuModel.getIowaitTime()
       + cpuModel.getIrqTime()
       + cpuModel.getSoftirqTime()
       + cpuModel.getStealstolenTime()
       + cpuModel.getGuestTime();
 }