diff options
author | Christopher Tate <ctate@google.com> | 2011-11-28 18:00:36 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-11-28 18:00:36 -0800 |
commit | 2f9e260185e9c83800ba14fdc7abeb95a399f526 (patch) | |
tree | c5d16719f89d9a57e97004ee4e724ab97714736f /tests | |
parent | 462a9da4c3525ff7d9bf599ccf1b79e58a2bd4f2 (diff) | |
parent | 6d7bd049b02cd24429e540b764c44c8371b7d5eb (diff) | |
download | frameworks_base-2f9e260185e9c83800ba14fdc7abeb95a399f526.zip frameworks_base-2f9e260185e9c83800ba14fdc7abeb95a399f526.tar.gz frameworks_base-2f9e260185e9c83800ba14fdc7abeb95a399f526.tar.bz2 |
am 6d7bd049: am 05160615: Merge "Add iteration-limited mode to FrameworkPerf" into ics-mr1
* commit '6d7bd049b02cd24429e540b764c44c8371b7d5eb':
Add iteration-limited mode to FrameworkPerf
Diffstat (limited to 'tests')
4 files changed, 61 insertions, 6 deletions
diff --git a/tests/FrameworkPerf/res/layout/main.xml b/tests/FrameworkPerf/res/layout/main.xml index 7812648..e00ad92 100644 --- a/tests/FrameworkPerf/res/layout/main.xml +++ b/tests/FrameworkPerf/res/layout/main.xml @@ -66,7 +66,24 @@ > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" + android:text="Limit by: " + /> + <Spinner android:id="@+id/limitspinner" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:drawSelectorOnTop="true" + /> + </LinearLayout> + + <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="Test time (ms): " + android:id="@+id/limitlabel" /> <EditText android:id="@+id/testtime" android:layout_width="match_parent" diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java index 8ee5978..30a968f 100644 --- a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java @@ -50,6 +50,8 @@ public class FrameworkPerfActivity extends Activity Spinner mFgSpinner; Spinner mBgSpinner; + Spinner mLimitSpinner; + TextView mLimitLabel; TextView mTestTime; Button mStartButton; Button mStopButton; @@ -58,10 +60,12 @@ public class FrameworkPerfActivity extends Activity PowerManager.WakeLock mPartialWakeLock; long mMaxRunTime = 5000; + boolean mLimitIsIterations; boolean mStarted; final String[] mAvailOpLabels; final String[] mAvailOpDescriptions; + final String[] mLimitLabels = { "Time", "Iterations" }; int mFgTestIndex = -1; int mBgTestIndex = -1; @@ -169,8 +173,15 @@ public class FrameworkPerfActivity extends Activity adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mBgSpinner.setAdapter(adapter); mBgSpinner.setOnItemSelectedListener(this); + mLimitSpinner = (Spinner) findViewById(R.id.limitspinner); + adapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, mLimitLabels); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mLimitSpinner.setAdapter(adapter); + mLimitSpinner.setOnItemSelectedListener(this); mTestTime = (TextView)findViewById(R.id.testtime); + mLimitLabel = (TextView)findViewById(R.id.limitlabel); mStartButton = (Button)findViewById(R.id.start); mStartButton.setOnClickListener(new View.OnClickListener() { @@ -196,16 +207,23 @@ public class FrameworkPerfActivity extends Activity @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { - if (parent == mFgSpinner || parent == mBgSpinner) { + if (parent == mFgSpinner || parent == mBgSpinner || parent == mLimitSpinner) { TestService.Op op = TestService.mAvailOps[position]; if (parent == mFgSpinner) { mFgTestIndex = position; mFgTest = op; ((TextView)findViewById(R.id.fgtext)).setText(mAvailOpDescriptions[position]); - } else { + } else if (parent == mBgSpinner) { mBgTestIndex = position; mBgTest = op; ((TextView)findViewById(R.id.bgtext)).setText(mAvailOpDescriptions[position]); + } else if (parent == mLimitSpinner) { + mLimitIsIterations = (position != 0); + if (mLimitIsIterations) { + mLimitLabel.setText("Iterations: "); + } else { + mLimitLabel.setText("Test time (ms): "); + } } } } @@ -234,7 +252,11 @@ public class FrameworkPerfActivity extends Activity return; } TestArgs args = new TestArgs(); - args.maxTime = mMaxRunTime; + if (mLimitIsIterations) { + args.maxOps = mMaxRunTime; + } else { + args.maxTime = mMaxRunTime; + } if (mFgTestIndex == 0 && mBgTestIndex == 0) { args.combOp = mCurOpIndex; } else if (mFgTestIndex != 0 && mBgTestIndex != 0) { @@ -376,6 +398,7 @@ public class FrameworkPerfActivity extends Activity mTestTime.setEnabled(false); mFgSpinner.setEnabled(false); mBgSpinner.setEnabled(false); + mLimitSpinner.setEnabled(false); updateWakeLock(); startService(new Intent(this, SchedulerService.class)); mCurOpIndex = 0; @@ -397,6 +420,7 @@ public class FrameworkPerfActivity extends Activity mTestTime.setEnabled(true); mFgSpinner.setEnabled(true); mBgSpinner.setEnabled(true); + mLimitSpinner.setEnabled(true); updateWakeLock(); stopService(new Intent(this, SchedulerService.class)); synchronized (mResults) { diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java b/tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java index f2f7c56..2fe38aa 100644 --- a/tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java @@ -21,6 +21,7 @@ import android.os.Parcelable; public class TestArgs implements Parcelable { long maxTime; + long maxOps = -1; int combOp = -1; int fgOp = -1; int bgOp = -1; @@ -30,6 +31,7 @@ public class TestArgs implements Parcelable { public TestArgs(Parcel source) { maxTime = source.readLong(); + maxOps = source.readLong(); combOp = source.readInt(); fgOp = source.readInt(); bgOp = source.readInt(); @@ -43,6 +45,7 @@ public class TestArgs implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeLong(maxTime); + dest.writeLong(maxOps); dest.writeInt(combOp); dest.writeInt(fgOp); dest.writeInt(bgOp); diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java b/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java index 8cf1ac2..a8c43e9 100644 --- a/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java @@ -224,6 +224,7 @@ public class TestService extends Service { public class TestRunner { Handler mHandler; long mMaxRunTime; + long mMaxOps; Op mForegroundOp; Op mBackgroundOp; Runnable mDoneCallback; @@ -277,6 +278,7 @@ public class TestService extends Service { public void run(Handler handler, TestArgs args, Runnable doneCallback) { mHandler = handler; mMaxRunTime = args.maxTime; + mMaxOps = args.maxOps; if (args.combOp >= 0) { mForegroundOp = mOpPairs[args.combOp]; mBackgroundOp = mOpPairs[args.combOp+1]; @@ -352,9 +354,18 @@ public class TestService extends Service { if (!mBackgroundRunning && !mForegroundRunning) { return false; } - long now = SystemClock.uptimeMillis(); - if (now > (mStartTime+mMaxRunTime)) { - return false; + if (mMaxOps > 0) { + // iteration-limited case + if (mForegroundOps >= mMaxOps) { + return false; + } + mForegroundOps++; + } else { + // time-limited case + long now = SystemClock.uptimeMillis(); + if (now > (mStartTime+mMaxRunTime)) { + return false; + } } return true; } |