summaryrefslogtreecommitdiff
path: root/apct-tests/perftests/utils
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2016-11-02 11:14:47 -0700
committerJohn Reck <jreck@google.com>2016-11-02 14:49:51 -0700
commit3acf0382da22cda88234e599cd81b1ff5441cc35 (patch)
treebc7726502fc2fb9bda4504d15c051a14c35ccc54 /apct-tests/perftests/utils
parent99449eea6cfe174eba269b3cfff06e6533d6314e (diff)
Add benchmarks for View inflation
Also speed up RenderNode creation: Use finalizer() instead of NativeAllocationRegistry, this shaves ~3us off of creation currently Avoid instanceof, instead have SurfaceView explicitly ask for updates. Remove unused method call. Test: ran benchmarks Change-Id: I3117fdf72313a4e6a9965baca9f2a8b855c19b34
Diffstat (limited to 'apct-tests/perftests/utils')
-rw-r--r--apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java b/apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java
index 519d5248a347..fd393e9d070c 100644
--- a/apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java
+++ b/apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java
@@ -19,8 +19,11 @@ package android.perftests.utils;
import android.app.Activity;
import android.app.Instrumentation;
import android.os.Bundle;
+import android.os.Debug;
+import android.support.test.InstrumentationRegistry;
import android.util.Log;
+import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
@@ -45,6 +48,7 @@ import java.util.concurrent.TimeUnit;
public final class BenchmarkState {
private static final String TAG = "BenchmarkState";
+ private static final boolean ENABLE_PROFILING = false;
private static final int NOT_STARTED = 0; // The benchmark has not started yet.
private static final int WARMUP = 1; // The benchmark is warming up.
@@ -146,6 +150,11 @@ public final class BenchmarkState {
}
private void beginBenchmark(long warmupDuration, int iterations) {
+ if (ENABLE_PROFILING) {
+ File f = new File(InstrumentationRegistry.getContext().getDataDir(), "benchprof");
+ Log.d(TAG, "Tracing to: " + f.getAbsolutePath());
+ Debug.startMethodTracingSampling(f.getAbsolutePath(), 16 * 1024 * 1024, 100);
+ }
mMaxIterations = (int) (TARGET_TEST_DURATION_NS / (warmupDuration / iterations));
mMaxIterations = Math.min(MAX_TEST_ITERATIONS,
Math.max(mMaxIterations, MIN_TEST_ITERATIONS));
@@ -161,6 +170,9 @@ public final class BenchmarkState {
mResults.add((currentTime - mStartTimeNs - mPausedDurationNs) / mMaxIterations);
mRepeatCount++;
if (mRepeatCount >= REPEAT_COUNT) {
+ if (ENABLE_PROFILING) {
+ Debug.stopMethodTracing();
+ }
calculateSatistics();
mState = FINISHED;
return false;