diff options
author | Dianne Hackborn <hackbod@google.com> | 2011-10-31 15:39:59 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2011-10-31 16:52:34 -0700 |
commit | 2c84cfc001fb92a71811bf7384b7f865ff31ff9d (patch) | |
tree | 1d43eda4854e37a553b85ce759ea4fffd41c9edb /tests/FrameworkPerf | |
parent | dd79b4c85a9dd2c2ad702ea2137fe2a076567fa1 (diff) | |
download | frameworks_base-2c84cfc001fb92a71811bf7384b7f865ff31ff9d.zip frameworks_base-2c84cfc001fb92a71811bf7384b7f865ff31ff9d.tar.gz frameworks_base-2c84cfc001fb92a71811bf7384b7f865ff31ff9d.tar.bz2 |
Various performance and other work.
- IME service now switches between visible and perceptible depending on
whether it is being showm, allowing us to more aggressively free its
memory when not shown.
- The activity display time is no longer delayed by the activity
transition animation.
- New -R (repeat) option for launching activities with the am command.
- Improved some documentation on Loader to be clear about some methods
that apps should not normally call.
- FrameworkPerf test now allows you to select individual tests to run.
Change-Id: Id1f73de66dc93d63212183958a72119ad174318b
Diffstat (limited to 'tests/FrameworkPerf')
4 files changed, 178 insertions, 17 deletions
diff --git a/tests/FrameworkPerf/AndroidManifest.xml b/tests/FrameworkPerf/AndroidManifest.xml index f69d550..c3fc837 100644 --- a/tests/FrameworkPerf/AndroidManifest.xml +++ b/tests/FrameworkPerf/AndroidManifest.xml @@ -13,5 +13,7 @@ </activity> <service android:name="SchedulerService"> </service> + <receiver android:name="Receiver" android:exported="true"> + </receiver> </application> </manifest> diff --git a/tests/FrameworkPerf/res/layout/main.xml b/tests/FrameworkPerf/res/layout/main.xml index 2e9c500..8b54118 100644 --- a/tests/FrameworkPerf/res/layout/main.xml +++ b/tests/FrameworkPerf/res/layout/main.xml @@ -20,11 +20,50 @@ android:orientation="vertical" > - <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > + <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="Foreground: " + /> + <Spinner android:id="@+id/fgspinner" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:drawSelectorOnTop="true" + /> + </LinearLayout> + <TextView android:id="@+id/fgtext" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceSmall" + /> + + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_marginTop="10dp" + > + <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="Background: " + /> + <Spinner android:id="@+id/bgspinner" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:drawSelectorOnTop="true" + /> + </LinearLayout> + <TextView android:id="@+id/bgtext" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceSmall" + /> + + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_marginTop="10dp" + > <Button android:id="@+id/start" android:layout_width="wrap_content" android:layout_height="wrap_content" @@ -37,18 +76,13 @@ /> </LinearLayout> - <ScrollView android:id="@+id/scroll" + <TextView android:id="@+id/log" android:layout_width="match_parent" android:layout_height="0px" android:layout_weight="1" - > - <TextView android:id="@+id/log" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="25dp" - android:textSize="12sp" - android:textColor="#ffffffff" - /> - </ScrollView> + android:layout_marginTop="10dp" + android:textSize="12sp" + android:textColor="#ffffffff" + /> </LinearLayout> diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java index 69a6a58..66e788c 100644 --- a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java @@ -34,6 +34,9 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Spinner; import android.widget.TextView; import java.io.File; @@ -46,11 +49,14 @@ import java.util.ArrayList; /** * So you thought sync used up your battery life. */ -public class FrameworkPerfActivity extends Activity { +public class FrameworkPerfActivity extends Activity + implements AdapterView.OnItemSelectedListener { static final String TAG = "Perf"; final Handler mHandler = new Handler(); + Spinner mFgSpinner; + Spinner mBgSpinner; TextView mLog; PowerManager.WakeLock mPartialWakeLock; @@ -109,6 +115,11 @@ public class FrameworkPerfActivity extends Activity { new SchedulerOp(), new MethodCallOp(), new IpcOp(), + new CreateFileOp(), + new CreateWriteFileOp(), + new CreateWriteSyncFileOp(), + new WriteFileOp(), + new ReadFileOp(), new ParseXmlResOp(), new ParseLargeXmlResOp(), new LoadSmallBitmapOp(), @@ -116,7 +127,12 @@ public class FrameworkPerfActivity extends Activity { new LoadSmallScaledBitmapOp(), new LoadLargeScaledBitmapOp(), }; - + + final String[] mAvailOpLabels; + final String[] mAvailOpDescriptions; + + Op mFgTest; + Op mBgTest; int mCurOpIndex = 0; class RunResult { @@ -149,6 +165,21 @@ public class FrameworkPerfActivity extends Activity { final ArrayList<RunResult> mResults = new ArrayList<RunResult>(); + public FrameworkPerfActivity() { + mAvailOpLabels = new String[mAvailOps.length]; + mAvailOpDescriptions = new String[mAvailOps.length]; + for (int i=0; i<mAvailOps.length; i++) { + Op op = mAvailOps[i]; + if (op.getClass() == NoOp.class) { + mAvailOpLabels[i] = "All"; + mAvailOpDescriptions[i] = "All tests"; + } else { + mAvailOpLabels[i] = op.getName(); + mAvailOpDescriptions[i] = op.getLongName(); + } + } + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -157,6 +188,19 @@ public class FrameworkPerfActivity extends Activity { // in res/layout/hello_activity.xml setContentView(R.layout.main); + mFgSpinner = (Spinner) findViewById(R.id.fgspinner); + ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, mAvailOpLabels); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mFgSpinner.setAdapter(adapter); + mFgSpinner.setOnItemSelectedListener(this); + mBgSpinner = (Spinner) findViewById(R.id.bgspinner); + adapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, mAvailOpLabels); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mBgSpinner.setAdapter(adapter); + mBgSpinner.setOnItemSelectedListener(this); + findViewById(R.id.start).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startRunning(); @@ -175,6 +219,30 @@ public class FrameworkPerfActivity extends Activity { } @Override + public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { + if (parent == mFgSpinner || parent == mBgSpinner) { + Spinner spinner = (Spinner)parent; + Op op = mAvailOps[position]; + if (op.getClass() == NoOp.class) { + op = null; + } + if (parent == mFgSpinner) { + mFgTest = op; + ((TextView)findViewById(R.id.fgtext)).setText(mAvailOpDescriptions[position]); + } else { + mBgTest = op; + ((TextView)findViewById(R.id.bgtext)).setText(mAvailOpDescriptions[position]); + } + } + } + + @Override + public void onNothingSelected(AdapterView<?> parent) { + // TODO Auto-generated method stub + + } + + @Override public void onResume() { super.onResume(); } @@ -189,7 +257,21 @@ public class FrameworkPerfActivity extends Activity { } void startCurOp() { - mRunner.run(mHandler, mOpPairs[mCurOpIndex], mOpPairs[mCurOpIndex+1], new Runnable() { + Op fgOp, bgOp; + if (mFgTest == null && mBgTest == null) { + fgOp = mOpPairs[mCurOpIndex]; + bgOp = mOpPairs[mCurOpIndex+1]; + } else if (mFgTest != null && mBgTest != null) { + fgOp = mFgTest; + bgOp = mBgTest; + } else if (mFgTest != null) { + fgOp = mFgTest; + bgOp = mAvailOps[mCurOpIndex]; + } else { + fgOp = mAvailOps[mCurOpIndex]; + bgOp = mBgTest; + } + mRunner.run(mHandler, fgOp, bgOp, new Runnable() { @Override public void run() { RunResult result = new RunResult(mRunner); log(String.format("%s: fg=%d*%gms/op (%dms) / bg=%d*%gms/op (%dms)", @@ -201,8 +283,21 @@ public class FrameworkPerfActivity extends Activity { stopRunning(); return; } - mCurOpIndex+=2; - if (mCurOpIndex >= mOpPairs.length) { + if (mFgTest != null && mBgTest != null) { + log("Finished"); + stopRunning(); + return; + } + if (mFgTest == null && mBgTest == null) { + mCurOpIndex+=2; + if (mCurOpIndex >= mOpPairs.length) { + log("Finished"); + stopRunning(); + return; + } + } + mCurOpIndex++; + if (mCurOpIndex >= mAvailOps.length) { log("Finished"); stopRunning(); return; diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/Receiver.java b/tests/FrameworkPerf/src/com/android/frameworkperf/Receiver.java new file mode 100644 index 0000000..e17d0a7 --- /dev/null +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/Receiver.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.frameworkperf; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +/** + * Allow launching as an empty process. + */ +public class Receiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + } +} |