Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33d4dde0 authored by Guang Zhu's avatar Guang Zhu Committed by Android Git Automerger
Browse files

am 1753fd00: am 3af8b699: Merge "add a self instrumentation into framework perf app" into ics-mr1

* commit '1753fd00':
  add a self instrumentation into framework perf app
parents b9fc0a4d 1753fd00
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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)
+6 −0
Original line number Diff line number Diff line
@@ -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>
+24 −13
Original line number Diff line number Diff line
@@ -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));
        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());
            synchronized (mResults) {
                mResults.clear();
            }
            startCurOp();
        }
    }
@@ -393,6 +399,7 @@ public class FrameworkPerfActivity extends Activity
            mBgSpinner.setEnabled(true);
            updateWakeLock();
            stopService(new Intent(this, SchedulerService.class));
            synchronized (mResults) {
                for (int i=0; i<mResults.size(); i++) {
                    RunResult result = mResults.get(i);
                    float fgMsPerOp = result.getFgMsPerOp();
@@ -406,6 +413,10 @@ public class FrameworkPerfActivity extends Activity
                            + "\t" + result.bgLongName);
                }
            }
            synchronized (mResultNotifier) {
                mResultNotifier.notifyAll();
            }
        }
    }

    void updateWakeLock() {
+41 −0
Original line number Diff line number Diff line
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);
    }
}