Changing benchmark structure.
Now runs N iterations and the sum of the FPSs gives the score.
Minor: changed make file to only build on Linux.
Change-Id: I5b9b2f4b1889b6c55d1828615f1afc067e3ec26d
diff --git a/suite/pts/deviceTests/opengl/Android.mk b/suite/pts/deviceTests/opengl/Android.mk
index 2294e96..4f67de7 100644
--- a/suite/pts/deviceTests/opengl/Android.mk
+++ b/suite/pts/deviceTests/opengl/Android.mk
@@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# build only for linux
+ifeq ($(HOST_OS),linux)
+
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
@@ -33,3 +36,5 @@
include $(BUILD_CTS_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))
+
+endif # linux
\ No newline at end of file
diff --git a/suite/pts/deviceTests/opengl/jni/contextswitch/ContextSwitchRenderer.cpp b/suite/pts/deviceTests/opengl/jni/contextswitch/ContextSwitchRenderer.cpp
index 8e4b7e2..0d85cae 100644
--- a/suite/pts/deviceTests/opengl/jni/contextswitch/ContextSwitchRenderer.cpp
+++ b/suite/pts/deviceTests/opengl/jni/contextswitch/ContextSwitchRenderer.cpp
@@ -111,7 +111,7 @@
}
// Setup textures.
- mTextureIds[i] = GLUtils::genRandTex(2, 2);
+ mTextureIds[i] = GLUtils::genRandTex(64, 64);
if (mTextureIds[i] == 0) {
return false;
}
diff --git a/suite/pts/deviceTests/opengl/src/com/android/pts/opengl/primitive/GLActivity.java b/suite/pts/deviceTests/opengl/src/com/android/pts/opengl/primitive/GLActivity.java
index dece656..911ba6d 100644
--- a/suite/pts/deviceTests/opengl/src/com/android/pts/opengl/primitive/GLActivity.java
+++ b/suite/pts/deviceTests/opengl/src/com/android/pts/opengl/primitive/GLActivity.java
@@ -39,17 +39,17 @@
*/
public final static String INTENT_EXTRA_OFFSCREEN = "offscreen";
/**
- * Holds the number of milliseconds to wait before timing out.
- */
- public final static String INTENT_EXTRA_TIMEOUT = "timeout";
- /**
- * The minimum number of frames per second the device must achieve to pass.
- */
- public final static String INTENT_EXTRA_MIN_FPS = "min_fps";
- /**
* The number of frames to render for each workload.
*/
public final static String INTENT_EXTRA_NUM_FRAMES = "num_frames";
+ /**
+ * The number of iterations to run, the workload increases with each iteration.
+ */
+ public final static String INTENT_EXTRA_NUM_ITERATIONS = "num_iterations";
+ /**
+ * The number of milliseconds to wait before timing out.
+ */
+ public final static String INTENT_EXTRA_TIMEOUT = "timeout";
private Worker runner;
private volatile Exception mException;
@@ -57,12 +57,10 @@
private Benchmark mBenchmark;
private boolean mOffscreen;
- private int mTimeout;
- private int mMinFps;
private int mNumFrames;
- private volatile int mWorkload = 0;
-
- public ArrayList<Double> fpsValues = new ArrayList<Double>();
+ private int mNumIterations;
+ private int mTimeout;
+ private double[] mFpsValues;
@Override
public void onCreate(Bundle data) {
@@ -71,15 +69,16 @@
Intent intent = getIntent();
mBenchmark = Benchmark.valueOf(intent.getStringExtra(INTENT_EXTRA_BENCHMARK_NAME));
mOffscreen = intent.getBooleanExtra(INTENT_EXTRA_OFFSCREEN, false);
- mTimeout = intent.getIntExtra(INTENT_EXTRA_TIMEOUT, 0);
- mMinFps = intent.getIntExtra(INTENT_EXTRA_MIN_FPS, 0);
mNumFrames = intent.getIntExtra(INTENT_EXTRA_NUM_FRAMES, 0);
+ mNumIterations = intent.getIntExtra(INTENT_EXTRA_NUM_ITERATIONS, 0);
+ mTimeout = intent.getIntExtra(INTENT_EXTRA_TIMEOUT, 0);
+ mFpsValues = new double[mNumIterations];
Log.i(TAG, "Benchmark: " + mBenchmark);
Log.i(TAG, "Offscreen: " + mOffscreen);
- Log.i(TAG, "Time Out: " + mTimeout);
- Log.i(TAG, "Min FPS: " + mMinFps);
Log.i(TAG, "Num Frames: " + mNumFrames);
+ Log.i(TAG, "Num Iterations: " + mNumIterations);
+ Log.i(TAG, "Time Out: " + mTimeout);
SurfaceView surfaceView = new SurfaceView(this);
surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@@ -97,7 +96,7 @@
setContentView(surfaceView);
}
- public int waitForCompletion() throws Exception {
+ public double[] waitForCompletion() throws Exception {
// Creates, starts and waits for a worker to run the benchmark.
runner = new Worker();
runner.start();
@@ -105,7 +104,7 @@
if (mException != null) {
throw mException;
}
- return mWorkload;
+ return mFpsValues;
}
private static native void setupFullPipelineBenchmark(
@@ -127,7 +126,6 @@
*/
private class Worker extends Thread {
- private volatile boolean repeat = true;
private WatchDog watchDog;
@Override
@@ -136,43 +134,34 @@
watchDog = new WatchDog(mTimeout);
// Used to record the start and end time of the iteration.
double[] times = new double[2];
- while (repeat) {
+ boolean success = true;
+ for (int i = 0; i < mNumIterations && success; i++) {
// The workload to use for this iteration.
- int wl = mWorkload + 1;
+ int workload = i + 1;
// Setup the benchmark.
switch (mBenchmark) {
case FullPipeline:
- setupFullPipelineBenchmark(mSurface, mOffscreen, wl);
+ setupFullPipelineBenchmark(mSurface, mOffscreen, workload);
break;
case PixelOutput:
- setupPixelOutputBenchmark(mSurface, mOffscreen, wl);
+ setupPixelOutputBenchmark(mSurface, mOffscreen, workload);
break;
case ShaderPerf:
- setupShaderPerfBenchmark(mSurface, mOffscreen, wl);
+ setupShaderPerfBenchmark(mSurface, mOffscreen, workload);
break;
case ContextSwitch:
- setupContextSwitchBenchmark(mSurface, mOffscreen, wl);
+ setupContextSwitchBenchmark(mSurface, mOffscreen, workload);
break;
}
watchDog.start();
- boolean success = startBenchmark(mNumFrames, times);
+ success = startBenchmark(mNumFrames, times);
watchDog.stop();
// Start benchmark.
if (!success) {
mException = new Exception("Could not run benchmark");
- repeat = false;
} else {
// Calculate FPS.
- double totalTimeTaken = times[1] - times[0];
- double meanFps = mNumFrames * 1000.0f / totalTimeTaken;
- fpsValues.add(meanFps);
- if (meanFps >= mMinFps) {
- // Iteration passed, proceed to next one.
- mWorkload++;
- } else {
- // Iteration failed.
- repeat = false;
- }
+ mFpsValues[i] = mNumFrames * 1000.0f / (times[1] - times[0]);
}
}
}
diff --git a/suite/pts/deviceTests/opengl/src/com/android/pts/opengl/primitive/GLBenchmark.java b/suite/pts/deviceTests/opengl/src/com/android/pts/opengl/primitive/GLBenchmark.java
index bb63ee8..e0d592d 100644
--- a/suite/pts/deviceTests/opengl/src/com/android/pts/opengl/primitive/GLBenchmark.java
+++ b/suite/pts/deviceTests/opengl/src/com/android/pts/opengl/primitive/GLBenchmark.java
@@ -13,14 +13,15 @@
*/
package com.android.pts.opengl.primitive;
-import android.content.Intent;
-
import com.android.pts.util.PtsActivityInstrumentationTestCase2;
import com.android.pts.util.ResultType;
import com.android.pts.util.ResultUnit;
+import android.content.Intent;
+import android.cts.util.TimeoutReq;
import android.opengl.Matrix;
import android.util.Log;
+
import java.util.Arrays;
/**
@@ -35,29 +36,31 @@
/**
* Runs the full OpenGL ES 2.0 pipeline test offscreen.
*/
+ @TimeoutReq(minutes = 20)
public void testFullPipelineOffscreen() throws Exception {
- runBenchmark(Benchmark.FullPipeline, true, 500, 100000, 25, 0);
+ runBenchmark(Benchmark.FullPipeline, true, 500, 8, 500000);
}
/**
* Runs the full OpenGL ES 2.0 pipeline test onscreen.
*/
+ @TimeoutReq(minutes = 20)
public void testFullPipelineOnscreen() throws Exception {
- runBenchmark(Benchmark.FullPipeline, false, 500, 100000, 25, 0);
+ runBenchmark(Benchmark.FullPipeline, false, 500, 8, 500000);
}
/**
* Runs the pixel output test offscreen.
*/
public void testPixelOutputOffscreen() throws Exception {
- runBenchmark(Benchmark.PixelOutput, true, 500, 100000, 25, 0);
+ runBenchmark(Benchmark.PixelOutput, true, 500, 8, 500000);
}
/**
* Runs the pixel output test onscreen.
*/
public void testPixelOutputOnscreen() throws Exception {
- runBenchmark(Benchmark.PixelOutput, false, 500, 100000, 25, 0);
+ runBenchmark(Benchmark.PixelOutput, false, 500, 8, 500000);
}
/**
@@ -65,7 +68,7 @@
*/
public void testShaderPerfOffscreen() throws Exception {
// TODO(stuartscott): Not yet implemented
- // runBenchmark(Benchmark.ShaderPerf, true, 500, 100000, 25, 0);
+ // runBenchmark(Benchmark.ShaderPerf, true, 500, 8, 500000);
}
/**
@@ -73,57 +76,59 @@
*/
public void testShaderPerfOnscreen() throws Exception {
// TODO(stuartscott): Not yet implemented
- // runBenchmark(Benchmark.ShaderPerf, false, 500, 100000, 25, 0);
+ // runBenchmark(Benchmark.ShaderPerf, false, 500, 8, 500000);
}
/**
* Runs the context switch overhead test offscreen.
*/
public void testContextSwitchOffscreen() throws Exception {
- runBenchmark(Benchmark.ContextSwitch, true, 500, 100000, 25, 0);
+ runBenchmark(Benchmark.ContextSwitch, true, 500, 8, 500000);
}
/**
* Runs the context switch overhead test onscreen.
*/
public void testContextSwitchOnscreen() throws Exception {
- runBenchmark(Benchmark.ContextSwitch, false, 500, 100000, 25, 0);
+ runBenchmark(Benchmark.ContextSwitch, false, 500, 8, 500000);
}
/**
* Runs the specified test.
*
* @param benchmark An enum representing the benchmark to run.
+ * @param offscreen Whether to render the benchmark to an offscreen buffer rather than the screen.
* @param numFrames The number of frames to render.
+ * @param numIterations The number of iterations to run, each iteration has a bigger workload.
* @param timeout The milliseconds to wait for an iteration of the benchmark before timing out.
* @throws Exception If the benchmark could not be run.
*/
private void runBenchmark(Benchmark benchmark,
boolean offscreen,
int numFrames,
- int timeout,
- int minFps,
- int target) throws Exception {
+ int numIterations,
+ int timeout) throws Exception {
String benchmarkName = benchmark.toString();
Intent intent = new Intent();
intent.putExtra(GLActivity.INTENT_EXTRA_BENCHMARK_NAME, benchmarkName);
intent.putExtra(GLActivity.INTENT_EXTRA_OFFSCREEN, offscreen);
- intent.putExtra(GLActivity.INTENT_EXTRA_TIMEOUT, timeout);
- intent.putExtra(GLActivity.INTENT_EXTRA_MIN_FPS, minFps);
intent.putExtra(GLActivity.INTENT_EXTRA_NUM_FRAMES, numFrames);
+ intent.putExtra(GLActivity.INTENT_EXTRA_NUM_ITERATIONS, numIterations);
+ intent.putExtra(GLActivity.INTENT_EXTRA_TIMEOUT, timeout);
GLActivity activity = null;
setActivityIntent(intent);
try {
activity = getActivity();
- // Represents the maximum workload it can do whilst maintaining MIN_FPS.
- int workload = activity.waitForCompletion();
- if (workload < target) {
- throw new Exception("Benchmark did not reach " + target + ", got " + workload);
+ double[] fpsValues = activity.waitForCompletion();
+ double score = 0;
+ for (double d : fpsValues) {
+ score += d;
}
- Log.i(GLActivity.TAG, "FPS Values: " + activity.fpsValues);
- getReportLog()
- .printSummary("Workload", workload, ResultType.HIGHER_BETTER, ResultUnit.SCORE);
+ getReportLog().printArray(
+ "Fps Values", fpsValues, ResultType.HIGHER_BETTER, ResultUnit.FPS);
+ getReportLog().printSummary(
+ "Score", score, ResultType.HIGHER_BETTER, ResultUnit.SCORE);
} finally {
if (activity != null) {
activity.finish();