summaryrefslogtreecommitdiffstats
path: root/tests/FrameworkPerf
diff options
context:
space:
mode:
authorGuang Zhu <guangzhu@google.com>2011-11-17 14:32:41 -0800
committerGuang Zhu <guangzhu@google.com>2011-11-17 15:26:36 -0800
commit5eefd7711f63bc1b67ec927a8c43363f426121cc (patch)
treeaa97b0df76b29db4babd82ccbc858b226fd2f23e /tests/FrameworkPerf
parent302afb93d4fd908949ac796eda8343f9683e616a (diff)
downloadframeworks_base-5eefd7711f63bc1b67ec927a8c43363f426121cc.zip
frameworks_base-5eefd7711f63bc1b67ec927a8c43363f426121cc.tar.gz
frameworks_base-5eefd7711f63bc1b67ec927a8c43363f426121cc.tar.bz2
add a self instrumentation into framework perf app
It's essentially a test app on itself to facilitate running the perf automatically. Change-Id: I5aad3565e64719d219e76969a989ca80aa6df286
Diffstat (limited to 'tests/FrameworkPerf')
-rw-r--r--tests/FrameworkPerf/Android.mk2
-rw-r--r--tests/FrameworkPerf/AndroidManifest.xml6
-rw-r--r--tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java37
-rw-r--r--tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfTest.java41
4 files changed, 73 insertions, 13 deletions
diff --git a/tests/FrameworkPerf/Android.mk b/tests/FrameworkPerf/Android.mk
index 03893d6..2eb52f0 100644
--- a/tests/FrameworkPerf/Android.mk
+++ b/tests/FrameworkPerf/Android.mk
@@ -7,6 +7,8 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := FrameworkPerf
+LOCAL_JAVA_LIBRARIES := android.test.runner
+
LOCAL_AAPT_FLAGS = -c 120dpi,240dpi,160dpi,161dpi,320dpi,nodpi
include $(BUILD_PACKAGE)
diff --git a/tests/FrameworkPerf/AndroidManifest.xml b/tests/FrameworkPerf/AndroidManifest.xml
index e88f4fb..2591aaf 100644
--- a/tests/FrameworkPerf/AndroidManifest.xml
+++ b/tests/FrameworkPerf/AndroidManifest.xml
@@ -4,6 +4,7 @@
<uses-sdk android:minSdkVersion="5" />
<application android:hardwareAccelerated="false">
+ <uses-library android:name="android.test.runner" />
<activity android:name="FrameworkPerfActivity" android:label="Framework Perf">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -20,4 +21,9 @@
<receiver android:name="Receiver" android:exported="true">
</receiver>
</application>
+
+ <instrumentation android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.android.frameworkperf"
+ android:label="Framework Perf Runner"
+ />
</manifest>
diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java
index 175f227..8ee5978 100644
--- a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java
+++ b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java
@@ -73,6 +73,8 @@ public class FrameworkPerfActivity extends Activity
final ArrayList<RunResult> mResults = new ArrayList<RunResult>();
+ Object mResultNotifier = new Object();
+
class TestConnection implements ServiceConnection, IBinder.DeathRecipient {
Messenger mService;
boolean mLinked;
@@ -266,7 +268,9 @@ public class FrameworkPerfActivity extends Activity
log(String.format("%s: fg=%d*%gms/op (%dms) / bg=%d*%gms/op (%dms)",
result.name, result.fgOps, result.getFgMsPerOp(), result.fgTime,
result.bgOps, result.getBgMsPerOp(), result.bgTime));
- mResults.add(result);
+ synchronized (mResults) {
+ mResults.add(result);
+ }
if (!mStarted) {
log("Stop");
stopRunning();
@@ -376,7 +380,9 @@ public class FrameworkPerfActivity extends Activity
startService(new Intent(this, SchedulerService.class));
mCurOpIndex = 0;
mMaxRunTime = Integer.parseInt(mTestTime.getText().toString());
- mResults.clear();
+ synchronized (mResults) {
+ mResults.clear();
+ }
startCurOp();
}
}
@@ -393,17 +399,22 @@ public class FrameworkPerfActivity extends Activity
mBgSpinner.setEnabled(true);
updateWakeLock();
stopService(new Intent(this, SchedulerService.class));
- for (int i=0; i<mResults.size(); i++) {
- RunResult result = mResults.get(i);
- float fgMsPerOp = result.getFgMsPerOp();
- float bgMsPerOp = result.getBgMsPerOp();
- String fgMsPerOpStr = fgMsPerOp != 0 ? Float.toString(fgMsPerOp) : "";
- String bgMsPerOpStr = bgMsPerOp != 0 ? Float.toString(bgMsPerOp) : "";
- Log.i("PerfRes", "\t" + result.name + "\t" + result.fgOps
- + "\t" + result.getFgMsPerOp() + "\t" + result.fgTime
- + "\t" + result.fgLongName + "\t" + result.bgOps
- + "\t" + result.getBgMsPerOp() + "\t" + result.bgTime
- + "\t" + result.bgLongName);
+ synchronized (mResults) {
+ for (int i=0; i<mResults.size(); i++) {
+ RunResult result = mResults.get(i);
+ float fgMsPerOp = result.getFgMsPerOp();
+ float bgMsPerOp = result.getBgMsPerOp();
+ String fgMsPerOpStr = fgMsPerOp != 0 ? Float.toString(fgMsPerOp) : "";
+ String bgMsPerOpStr = bgMsPerOp != 0 ? Float.toString(bgMsPerOp) : "";
+ Log.i("PerfRes", "\t" + result.name + "\t" + result.fgOps
+ + "\t" + result.getFgMsPerOp() + "\t" + result.fgTime
+ + "\t" + result.fgLongName + "\t" + result.bgOps
+ + "\t" + result.getBgMsPerOp() + "\t" + result.bgTime
+ + "\t" + result.bgLongName);
+ }
+ }
+ synchronized (mResultNotifier) {
+ mResultNotifier.notifyAll();
}
}
}
diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfTest.java b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfTest.java
new file mode 100644
index 0000000..2a53b06
--- /dev/null
+++ b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfTest.java
@@ -0,0 +1,41 @@
+package com.android.frameworkperf;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.test.ActivityInstrumentationTestCase2;
+
+public class FrameworkPerfTest extends ActivityInstrumentationTestCase2<FrameworkPerfActivity> {
+
+ private static final int TEST_TIMEOUT = 15 * 60 * 1000; //15 minutes
+
+ public FrameworkPerfTest() {
+ super("com.android.frameworkperf", FrameworkPerfActivity.class);
+ }
+
+ public void testFrameworkPerf() {
+ final FrameworkPerfActivity activity = getActivity();
+ synchronized (activity.mResultNotifier) {
+ getInstrumentation().runOnMainSync(new Runnable() {
+ @Override
+ public void run() {
+ activity.startRunning();
+ }
+ });
+ try {
+ activity.mResultNotifier.wait(TEST_TIMEOUT);
+ } catch (InterruptedException e) {
+ fail("test interrupted.");
+ }
+ }
+ Bundle testResult = new Bundle();
+ synchronized (activity.mResults) {
+ assertTrue("test results were empty.", activity.mResults.size() > 0);
+ for (RunResult result : activity.mResults) {
+ testResult.putString(result.name, String.format("%f,%d,%d,%f,%d,%d",
+ result.getFgMsPerOp(), result.fgOps, result.fgTime,
+ result.getBgMsPerOp(), result.bgOps, result.bgTime));
+ }
+ }
+ getInstrumentation().sendStatus(Activity.RESULT_OK, testResult);
+ }
+}