From 714abd365ca764c4da9fa3302064006081da8a6a Mon Sep 17 00:00:00 2001 From: Kurt Nelson Date: Tue, 17 Oct 2017 15:34:07 -0700 Subject: [PATCH] Perftests for StrictMode Add perf tests for: * Disk read thread policy violation * URI permission VM policy violation * Disk read across binder thread policy violation lunch walleye-userdebug timeThreadViolation_mean=293735 timeThreadViolation_median=290845 timeThreadViolation_min=285718 timeThreadViolation_standardDeviation=8368 timeCrossBinderThreadViolationNoStrictMode_mean=1327809 timeCrossBinderThreadViolationNoStrictMode_median=1317313 timeCrossBinderThreadViolationNoStrictMode_min=1260868 timeCrossBinderThreadViolationNoStrictMode_standardDeviation=58085 timeCrossBinderThreadViolation_mean=2754359 timeCrossBinderThreadViolation_median=3170103 timeCrossBinderThreadViolation_min=1773987 timeCrossBinderThreadViolation_standardDeviation=704586 timeVmViolationNoStrictMode_mean=10764979 timeVmViolationNoStrictMode_median=9762317 timeVmViolationNoStrictMode_min=5187496 timeVmViolationNoStrictMode_standardDeviation=4099275 timeVmViolation_mean=20003781 timeVmViolation_median=21730129 timeVmViolation_min=14321899 timeVmViolation_standardDeviation=3837213 timeThreadViolationNoStrictMode_mean=237276 timeThreadViolationNoStrictMode_median=241457 timeThreadViolationNoStrictMode_min=227193 timeThreadViolationNoStrictMode_standardDeviation=8892 Bug: 65966451 Test: adb shell am instrument -w -e class android.os.StrictModeTest \ com.android.perftests.core/android.support.test.runner.AndroidJUnitRunner Change-Id: I97773e1060e21cf78649454973426985b33d3350 --- apct-tests/perftests/core/Android.mk | 5 +- apct-tests/perftests/core/AndroidManifest.xml | 1 + .../core/src/android/os/ISomeService.aidl | 5 + .../perftests/core/src/android/os/SomeService.java | 42 +++++++ .../core/src/android/os/StrictModeTest.java | 127 +++++++++++++++++++++ 5 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 apct-tests/perftests/core/src/android/os/ISomeService.aidl create mode 100644 apct-tests/perftests/core/src/android/os/SomeService.java create mode 100644 apct-tests/perftests/core/src/android/os/StrictModeTest.java diff --git a/apct-tests/perftests/core/Android.mk b/apct-tests/perftests/core/Android.mk index 200f92fb590c..f08b4025f95e 100644 --- a/apct-tests/perftests/core/Android.mk +++ b/apct-tests/perftests/core/Android.mk @@ -4,11 +4,14 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res -LOCAL_SRC_FILES := $(call all-java-files-under, src) +LOCAL_SRC_FILES := \ + $(call all-java-files-under, src) \ + src/android/os/ISomeService.aidl LOCAL_STATIC_JAVA_LIBRARIES := \ android-support-test \ apct-perftests-utils \ + guava \ legacy-android-test LOCAL_PACKAGE_NAME := CorePerfTests diff --git a/apct-tests/perftests/core/AndroidManifest.xml b/apct-tests/perftests/core/AndroidManifest.xml index a709ee3ff913..f27e8c82a303 100644 --- a/apct-tests/perftests/core/AndroidManifest.xml +++ b/apct-tests/perftests/core/AndroidManifest.xml @@ -5,6 +5,7 @@ + binder = SettableFuture.create(); + ServiceConnection connection = + new ServiceConnection() { + @Override + public void onServiceConnected(ComponentName className, IBinder service) { + binder.set(service); + } + + @Override + public void onServiceDisconnected(ComponentName arg0) { + binder.set(null); + } + }; + context.bindService( + new Intent(context, SomeService.class), connection, Context.BIND_AUTO_CREATE); + ISomeService someService = ISomeService.Stub.asInterface(binder.get()); + while (state.keepRunning()) { + // Violate strictmode heavily. + someService.readDisk(10); + } + context.unbindService(connection); + } +} -- 2.11.0