/** * Add a measured segment, and start measuring the next segment. Returns * collected data in a Bundle object. * * @param label description of code block between startTiming and * addIteration, and between two calls to addIteration, used * to label output * @return Runtime metrics stored as key/value pairs. Values are of type * long, and keys include: * <ul> * <li>{@link #METRIC_KEY_LABEL label} * <li>{@link #METRIC_KEY_CPU_TIME cpu_time} * <li>{@link #METRIC_KEY_EXECUTION_TIME execution_time} * </ul> */ public Bundle addIteration(String label) { mCpuTime = Process.getElapsedCpuTime() - mCpuTime; mExecTime = SystemClock.uptimeMillis() - mExecTime; Bundle iteration = new Bundle(); iteration.putString(METRIC_KEY_LABEL, label); iteration.putLong(METRIC_KEY_EXECUTION_TIME, mExecTime); iteration.putLong(METRIC_KEY_CPU_TIME, mCpuTime); mPerfMeasurement.getParcelableArrayList(METRIC_KEY_ITERATIONS).add(iteration); mExecTime = SystemClock.uptimeMillis(); mCpuTime = Process.getElapsedCpuTime(); return iteration; }
/** * Add a measured segment, and start measuring the next segment. Returns * collected data in a Bundle object. * * @param label description of code block between startTiming and * addIteration, and between two calls to addIteration, used * to label output * @return Runtime metrics stored as key/value pairs. Values are of type * long, and keys include: * <ul> * <li>{@link #METRIC_KEY_LABEL label} * <li>{@link #METRIC_KEY_CPU_TIME cpu_time} * <li>{@link #METRIC_KEY_EXECUTION_TIME execution_time} * </ul> */ public Bundle addIteration(String label) { mCpuTime = Process.getElapsedCpuTime() - mCpuTime; mExecTime = SystemClock.uptimeMillis() - mExecTime; Bundle iteration = new Bundle(); iteration.putString(METRIC_KEY_LABEL, label); iteration.putLong(METRIC_KEY_EXECUTION_TIME, mExecTime); iteration.putLong(METRIC_KEY_CPU_TIME, mCpuTime); mPerfMeasurement.getParcelableArrayList(METRIC_KEY_ITERATIONS).add(iteration); mExecTime = SystemClock.uptimeMillis(); mCpuTime = Process.getElapsedCpuTime(); return iteration; }
/** * Start measurement of user and cpu time. * * @param label description of code block between startTiming and * stopTiming, used to label output */ public void startTiming(String label) { if (mPerfWriter != null) mPerfWriter.writeStartTiming(label); mPerfMeasurement = new Bundle(); mPerfMeasurement.putParcelableArrayList( METRIC_KEY_ITERATIONS, new ArrayList<Parcelable>()); mExecTime = SystemClock.uptimeMillis(); mCpuTime = Process.getElapsedCpuTime(); }
/** * Start measurement of user and cpu time. * * @param label description of code block between startTiming and * stopTiming, used to label output */ public void startTiming(String label) { if (mPerfWriter != null) mPerfWriter.writeStartTiming(label); mPerfMeasurement = new Bundle(); mPerfMeasurement.putParcelableArrayList( METRIC_KEY_ITERATIONS, new ArrayList<Parcelable>()); mExecTime = SystemClock.uptimeMillis(); mCpuTime = Process.getElapsedCpuTime(); }
private void startPerformanceSnapshot() { // Create new snapshot mPerfSnapshot = new Bundle(); // Add initial binder counts Bundle binderCounts = getBinderCounts(); for (String key : binderCounts.keySet()) { mPerfSnapshot.putLong("pre_" + key, binderCounts.getLong(key)); } // Force a GC and zero out the performance counters. Do this // before reading initial CPU/wall-clock times so we don't include // the cost of this setup in our final metrics. startAllocCounting(); // Record CPU time up to this point, and start timing. Note: this // must happen at the end of this method, otherwise the timing will // include noise. mSnapshotExecTime = SystemClock.uptimeMillis(); mSnapshotCpuTime = Process.getElapsedCpuTime(); }
private void startPerformanceSnapshot() { // Create new snapshot mPerfSnapshot = new Bundle(); // Add initial binder counts Bundle binderCounts = getBinderCounts(); for (String key : binderCounts.keySet()) { mPerfSnapshot.putLong("pre_" + key, binderCounts.getLong(key)); } // Force a GC and zero out the performance counters. Do this // before reading initial CPU/wall-clock times so we don't include // the cost of this setup in our final metrics. startAllocCounting(); // Record CPU time up to this point, and start timing. Note: this // must happen at the end of this method, otherwise the timing will // include noise. mSnapshotExecTime = SystemClock.uptimeMillis(); mSnapshotCpuTime = Process.getElapsedCpuTime(); }
private void endPerformanceSnapshot() { mSnapshotCpuTime = Process.getElapsedCpuTime() - mSnapshotCpuTime; mSnapshotExecTime = SystemClock.uptimeMillis() - mSnapshotExecTime;
private void endPerformanceSnapshot() { mSnapshotCpuTime = Process.getElapsedCpuTime() - mSnapshotCpuTime; mSnapshotExecTime = SystemClock.uptimeMillis() - mSnapshotExecTime;