@SuppressWarnings("unchecked") public String statistic(int beginTime, int endTime) { Collections.sort(mInterruptList); DecimalFormat df = new DecimalFormat("0.0"); mWakeupRatio = (float) mWakeUpTotalTime / (mWakeUpTotalTime + mSleepTotalTime) * 100; StringBuilder sb = new StringBuilder(); sb.append("总唤醒次数: " + getWakekupCount()); sb.append("\n总唤醒时间: " + seconds2Hhmmss(getWakeUpTotalTime())); sb.append("\n总休眠时间: " + seconds2Hhmmss(getSleepTotalTime())); sb.append("\n唤醒比重: " + df.format(getWakeupRatio()) + "% \n\n"); sb.append("中断号:次数, 平均间隔, 平均时长, 中断名\n"); for (LogWakeup info : mInterruptList) { info.setAvgWakeupTime(); info.setName(mParser.getInterruptName(info.getIdentifier())); float intervalTime = (float) getTotalTime() / info.getTotalWakeupCount(); sb.append(info.getIdentifier() + ": "); sb.append(info.getTotalWakeupCount() + ", "); sb.append(df.format(intervalTime) + "s, "); sb.append(df.format(info.getAvgWakeupTime()) + "s, "); sb.append("\n " + info.getName() + " "); sb.append("\n"); } return sb.toString(); }
/** 增加中断时间 唤醒时间 */ public void addWakeupTime(ArrayList<Integer> irqNums, int addTime) { this.mWakeUpTotalTime += addTime; for (Integer irq : irqNums) { int index = getIndex(irq); if (index != -1) { mInterruptList.get(index).addWakeupTime(addTime); } else { LogWakeup info = new LogWakeup(irq); info.addWakeupTime(addTime); mInterruptList.add(info); } } }
/** 中断次数 加1 */ public void addWakeupCount(ArrayList<Integer> irqNums) { this.mWakekupCount++; for (Integer irq : irqNums) { int index = getIndex(irq); if (index != -1) { mInterruptList.get(index).addWakeupCount(); } else { LogWakeup info = new LogWakeup(irq); info.addWakeupCount(); mInterruptList.add(info); } } }