summaryrefslogtreecommitdiff
path: root/startop/apps
diff options
context:
space:
mode:
authorEric Holk <eholk@google.com>2019-10-11 17:12:24 -0700
committerEric Holk <eholk@google.com>2019-10-11 17:12:24 -0700
commit1017c9c2ec3a8660e490e7984adf036da7d92f00 (patch)
tree8bc39e0615d472c4fc35491776d2e8827957ee5a /startop/apps
parent3e4452b2756a6ec0592d4b407dd87b7495293945 (diff)
Add acquire/release wake lock benchmark
Change-Id: Iae151d18a80f5acfdd205d9af1d2ee677153b8db
Diffstat (limited to 'startop/apps')
-rw-r--r--startop/apps/test/AndroidManifest.xml2
-rw-r--r--startop/apps/test/src/SystemServerBenchmarks.java12
2 files changed, 12 insertions, 2 deletions
diff --git a/startop/apps/test/AndroidManifest.xml b/startop/apps/test/AndroidManifest.xml
index ba1be715700d..a5ac348f42d1 100644
--- a/startop/apps/test/AndroidManifest.xml
+++ b/startop/apps/test/AndroidManifest.xml
@@ -91,4 +91,6 @@
</application>
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
+
</manifest>
diff --git a/startop/apps/test/src/SystemServerBenchmarks.java b/startop/apps/test/src/SystemServerBenchmarks.java
index 2464fbf7691c..126c2c8f2db7 100644
--- a/startop/apps/test/src/SystemServerBenchmarks.java
+++ b/startop/apps/test/src/SystemServerBenchmarks.java
@@ -26,6 +26,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.AsyncTask;
+import android.os.PowerManager;
/**
* An interface for running benchmarks and collecting results. Used so we can have both an
@@ -161,12 +162,19 @@ class SystemServerBenchmarks {
});
// We use PendingIntent.getCreatorPackage, since
- // getPackageIntentForSender is not public to us, but getCreatorPackage
- // is just a thin wrapper around it.
+ // getPackageIntentForSender is not public to us, but getCreatorPackage
+ // is just a thin wrapper around it.
PendingIntent pi = PendingIntent.getActivity(parent, 0, new Intent(), 0);
benchmarks.addBenchmark("getPackageIntentForSender", () -> {
pi.getCreatorPackage();
});
+
+ PowerManager pwr = (PowerManager) parent.getSystemService(Context.POWER_SERVICE);
+ PowerManager.WakeLock wl = pwr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "benchmark tag");
+ benchmarks.addBenchmark("WakeLock Acquire/Release", () -> {
+ wl.acquire();
+ wl.release();
+ });
}
/**