summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-10-15 18:13:27 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-10-15 18:13:27 +0000
commit31b31c71016478d069276ca1801bda866b2e8aa0 (patch)
treedff1535ac241aab4806766ea6154b5f2c6cf7a79
parentaad41eb66719abb6a26ef318f92491e6a83a6a07 (diff)
parent1017c9c2ec3a8660e490e7984adf036da7d92f00 (diff)
Merge "Add acquire/release wake lock benchmark"
-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();
+ });
}
/**