diff options
| author | 2016-04-15 13:34:25 -0700 | |
|---|---|---|
| committer | 2016-04-19 11:27:11 -0700 | |
| commit | d2bc2ba778514731e1475d4178fe9fc1d782285f (patch) | |
| tree | fe161b714cfd4f4edb60775ee3186e9048e7015f | |
| parent | 1dbff801aeac52a4525f085d1346cc8741c00d30 (diff) | |
Add the wall clock time to dumpsys cpuinfo so it's easier to correlate with the logs.
Bug: 28113068
Change-Id: Ifa90192b0aa3f57ba6928f38199beb5b56bca7e6
| -rw-r--r-- | core/java/com/android/internal/os/ProcessCpuTracker.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/java/com/android/internal/os/ProcessCpuTracker.java b/core/java/com/android/internal/os/ProcessCpuTracker.java index d8319022f431..b7e571871086 100644 --- a/core/java/com/android/internal/os/ProcessCpuTracker.java +++ b/core/java/com/android/internal/os/ProcessCpuTracker.java @@ -34,9 +34,11 @@ import java.io.File; import java.io.FileInputStream; import java.io.PrintWriter; import java.io.StringWriter; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.Date; import java.util.StringTokenizer; public class ProcessCpuTracker { @@ -147,6 +149,9 @@ public class ProcessCpuTracker { private long mCurrentSampleRealTime; private long mLastSampleRealTime; + private long mCurrentSampleWallTime; + private long mLastSampleWallTime; + private long mBaseUserTime; private long mBaseSystemTime; private long mBaseIoWaitTime; @@ -305,6 +310,7 @@ public class ProcessCpuTracker { final long nowUptime = SystemClock.uptimeMillis(); final long nowRealtime = SystemClock.elapsedRealtime(); + final long nowWallTime = System.currentTimeMillis(); final long[] sysCpu = mSystemCpuData; if (Process.readProcFile("/proc/stat", SYSTEM_CPU_FORMAT, @@ -367,6 +373,8 @@ public class ProcessCpuTracker { mCurrentSampleTime = nowUptime; mLastSampleRealTime = mCurrentSampleRealTime; mCurrentSampleRealTime = nowRealtime; + mLastSampleWallTime = mCurrentSampleWallTime; + mCurrentSampleWallTime = nowWallTime; final StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreadDiskReads(); try { @@ -710,6 +718,8 @@ public class ProcessCpuTracker { } final public String printCurrentState(long now) { + final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + buildWorkingProcs(); StringWriter sw = new StringWriter(); @@ -727,6 +737,11 @@ public class ProcessCpuTracker { pw.print(mCurrentSampleTime-now); pw.print("ms later"); } + pw.print(" ("); + pw.print(sdf.format(new Date(mLastSampleWallTime))); + pw.print(" to "); + pw.print(sdf.format(new Date(mCurrentSampleWallTime))); + pw.print(")"); long sampleTime = mCurrentSampleTime - mLastSampleTime; long sampleRealTime = mCurrentSampleRealTime - mLastSampleRealTime; |