diff options
author | Alex Sakhartchouk <alexst@google.com> | 2011-11-17 14:08:47 -0800 |
---|---|---|
committer | Alex Sakhartchouk <alexst@google.com> | 2011-11-17 14:08:47 -0800 |
commit | 37333001cb7801ab510ce0216183bf8df2e93b08 (patch) | |
tree | 95eae1d8af85aab4dde39af614a794a93bf00851 /tests/RenderScriptTests/PerfTest/src/com/android/perftest | |
parent | 9ab5fa0aaadcfdc27e993caceececebb8141e01f (diff) | |
download | frameworks_base-37333001cb7801ab510ce0216183bf8df2e93b08.zip frameworks_base-37333001cb7801ab510ce0216183bf8df2e93b08.tar.gz frameworks_base-37333001cb7801ab510ce0216183bf8df2e93b08.tar.bz2 |
adding benchmark single test
Change-Id: I902579085bfee2f0bdc0bf4f38442f2f1569bf71
Diffstat (limited to 'tests/RenderScriptTests/PerfTest/src/com/android/perftest')
5 files changed, 50 insertions, 15 deletions
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBench.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBench.java index b336a4d..4ed42b4 100644 --- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBench.java +++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBench.java @@ -93,22 +93,36 @@ public class RsBench extends Activity { public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { - case R.id.benchmark_mode: - mView.setBenchmarkMode(); + case R.id.benchmark_all: + mView.setBenchmarkMode(-1); return true; - case R.id.debug_mode: + case R.id.benchmark_one: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Pick a Test"); builder.setItems(mView.getTestNames(), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), + "Starting to benchmark: " + mView.getTestNames()[item], + Toast.LENGTH_SHORT).show(); + mView.setBenchmarkMode(item); + } + }); + builder.show(); + return true; + case R.id.debug_mode: + AlertDialog.Builder debugBuilder = new AlertDialog.Builder(this); + debugBuilder.setTitle("Pick a Test"); + debugBuilder.setItems(mView.getTestNames(), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int item) { + Toast.makeText(getApplicationContext(), "Switching to: " + mView.getTestNames()[item], Toast.LENGTH_SHORT).show(); mView.setDebugMode(item); } }); - builder.show(); + debugBuilder.show(); return true; default: return super.onOptionsItemSelected(item); diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java index b8360d7..c51bd82 100644 --- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java +++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java @@ -248,8 +248,8 @@ public class RsBenchRS { mScript.invoke_setDebugMode(num); } - public void setBenchmarkMode() { - mScript.invoke_setBenchmarkMode(); + public void setBenchmarkMode(int benchNum) { + mScript.invoke_setBenchmarkMode(benchNum); } private void initRS() { diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchView.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchView.java index efcb463..004e6bf 100644 --- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchView.java +++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchView.java @@ -88,8 +88,8 @@ public class RsBenchView extends RSSurfaceView { return mRender.testIsFinished(); } - void setBenchmarkMode() { - mRender.setBenchmarkMode(); + void setBenchmarkMode(int benchNum) { + mRender.setBenchmarkMode(benchNum); } void setDebugMode(int num) { diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TextTest.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TextTest.java index 65290e7..ca9e660 100644 --- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TextTest.java +++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TextTest.java @@ -19,6 +19,7 @@ package com.android.perftest; import android.os.Environment; import android.content.res.Resources; import android.renderscript.*; +import android.util.DisplayMetrics; import android.util.Log; @@ -78,8 +79,12 @@ public class TextTest implements RsBenchBaseTest{ } void initTextScript() { + DisplayMetrics metrics = mRes.getDisplayMetrics(); + mTextScript = new ScriptC_text_test(mRS, mRes, R.raw.text_test); - mTextScript.set_gFontSans(Font.create(mRS, mRes, "sans-serif", Font.Style.NORMAL, 8)); - mTextScript.set_gFontSerif(Font.create(mRS, mRes, "serif", Font.Style.NORMAL, 8)); + mTextScript.set_gFontSans(Font.create(mRS, mRes, "sans-serif", + Font.Style.NORMAL, 8.0f / metrics.density)); + mTextScript.set_gFontSerif(Font.create(mRS, mRes, "serif", + Font.Style.NORMAL, 8.0f / metrics.density)); } } diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs index 68f2814..2b849a2 100644 --- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs +++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs @@ -122,6 +122,7 @@ static bool checkInit() { } static int benchMode = 0; +static bool benchmarkSingleTest = false; static int benchSubMode = 0; static int runningLoops = 0; static bool sendMsgFlag = false; @@ -133,9 +134,16 @@ void setDebugMode(int testNumber) { rsgClearAllRenderTargets(); } -void setBenchmarkMode() { +void setBenchmarkMode(int testNumber) { gIsDebugMode = false; - benchMode = 0; + if (testNumber == -1) { + benchmarkSingleTest = false; + benchMode = 0; + } else { + benchmarkSingleTest = true; + benchMode = testNumber; + } + runningLoops = 0; } @@ -190,9 +198,13 @@ static void benchmark() { rsDebug("Finishes test ", fps); gResultBuffer[benchMode] = fps; - drawOffscreenResult(0, 0, - gRenderSurfaceW / 2, - gRenderSurfaceH / 2); + int bufferW = rsAllocationGetDimX(gRenderBufferColor); + int bufferH = rsAllocationGetDimY(gRenderBufferColor); + + int quadW = gRenderSurfaceW / 2; + int quadH = (quadW * bufferH) / bufferW; + drawOffscreenResult(0, 0, quadW, quadH); + int left = 0, right = 0, top = 0, bottom = 0; uint width = rsgGetWidth(); uint height = rsgGetHeight(); @@ -202,6 +214,10 @@ static void benchmark() { rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f); rsgDrawText(gTestScripts[benchMode].testName, 2 -left, height - 2 + bottom); + if (benchmarkSingleTest) { + return; + } + benchMode ++; int testCount = rsAllocationGetDimX(rsGetAllocation(gTestScripts)); if (benchMode == testCount) { |