Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b7903e2 authored by Joe Onorato's avatar Joe Onorato Committed by android-build-merger
Browse files

Merge "Add the wall clock time to dumpsys cpuinfo so it\'s easier to correlate...

Merge "Add the wall clock time to dumpsys cpuinfo so it\'s easier to correlate with the logs." into nyc-dev
am: 6bf86d5e

* commit '6bf86d5e':
  Add the wall clock time to dumpsys cpuinfo so it's easier to correlate with the logs.

Change-Id: Icf955f4bcafdfd457a6d049df36933a7e12a39a5
parents c8984996 6bf86d5e
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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;