Loading tests/FrameworkPerf/res/layout/main.xml +17 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,22 @@ 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="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" Loading @@ -67,6 +83,7 @@ <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" Loading tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java +27 −3 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ public class FrameworkPerfActivity extends Activity Spinner mFgSpinner; Spinner mBgSpinner; Spinner mLimitSpinner; TextView mLimitLabel; TextView mTestTime; Button mStartButton; Button mStopButton; Loading @@ -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; Loading Loading @@ -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() { Loading @@ -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): "); } } } } Loading Loading @@ -234,7 +252,11 @@ public class FrameworkPerfActivity extends Activity return; } TestArgs args = new TestArgs(); if (mLimitIsIterations) { args.maxOps = mMaxRunTime; } else { args.maxTime = mMaxRunTime; } if (mFgTestIndex == 0 && mBgTestIndex == 0) { args.combOp = mCurOpIndex; } else if (mFgTestIndex != 0 && mBgTestIndex != 0) { Loading Loading @@ -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; Loading @@ -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) { Loading tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java +3 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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(); Loading @@ -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); Loading tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java +14 −3 Original line number Diff line number Diff line Loading @@ -224,6 +224,7 @@ public class TestService extends Service { public class TestRunner { Handler mHandler; long mMaxRunTime; long mMaxOps; Op mForegroundOp; Op mBackgroundOp; Runnable mDoneCallback; Loading Loading @@ -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]; Loading Loading @@ -352,10 +354,19 @@ public class TestService extends Service { if (!mBackgroundRunning && !mForegroundRunning) { 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; } } Loading Loading
tests/FrameworkPerf/res/layout/main.xml +17 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,22 @@ 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="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" Loading @@ -67,6 +83,7 @@ <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" Loading
tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java +27 −3 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ public class FrameworkPerfActivity extends Activity Spinner mFgSpinner; Spinner mBgSpinner; Spinner mLimitSpinner; TextView mLimitLabel; TextView mTestTime; Button mStartButton; Button mStopButton; Loading @@ -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; Loading Loading @@ -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() { Loading @@ -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): "); } } } } Loading Loading @@ -234,7 +252,11 @@ public class FrameworkPerfActivity extends Activity return; } TestArgs args = new TestArgs(); if (mLimitIsIterations) { args.maxOps = mMaxRunTime; } else { args.maxTime = mMaxRunTime; } if (mFgTestIndex == 0 && mBgTestIndex == 0) { args.combOp = mCurOpIndex; } else if (mFgTestIndex != 0 && mBgTestIndex != 0) { Loading Loading @@ -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; Loading @@ -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) { Loading
tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java +3 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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(); Loading @@ -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); Loading
tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java +14 −3 Original line number Diff line number Diff line Loading @@ -224,6 +224,7 @@ public class TestService extends Service { public class TestRunner { Handler mHandler; long mMaxRunTime; long mMaxOps; Op mForegroundOp; Op mBackgroundOp; Runnable mDoneCallback; Loading Loading @@ -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]; Loading Loading @@ -352,10 +354,19 @@ public class TestService extends Service { if (!mBackgroundRunning && !mForegroundRunning) { 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; } } Loading