From 5de7657ac2aea7ae671e2cadb05dcb6207a51404 Mon Sep 17 00:00:00 2001 From: Alex Sakhartchouk Date: Tue, 6 Dec 2011 14:49:12 -0800 Subject: Fixing file writing bug Change-Id: I01b6fa9f14ecf01e8957cb1b9277ba88eea46845 --- .../src/com/android/perftest/FillTest.java | 3 +++ .../src/com/android/perftest/MeshTest.java | 3 +++ .../src/com/android/perftest/RsBenchRS.java | 30 +++++++++++++++------- .../src/com/android/perftest/TextTest.java | 3 +++ .../src/com/android/perftest/TorusTest.java | 3 +++ .../PerfTest/src/com/android/perftest/UiTest.java | 3 +++ .../PerfTest/src/com/android/perftest/rsbench.rs | 4 ++- 7 files changed, 39 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/FillTest.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/FillTest.java index 06b4af7..ba70c71 100644 --- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/FillTest.java +++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/FillTest.java @@ -62,6 +62,9 @@ public class FillTest implements RsBenchBaseTest{ mTests[index].testName = Allocation.createFromString(mRS, mNames[index], Allocation.USAGE_SCRIPT); + mTests[index].debugName = RsBenchRS.createZeroTerminatedAlloc(mRS, + mNames[index], + Allocation.USAGE_SCRIPT); ScriptField_FillTestData_s.Item dataItem = new ScriptField_FillTestData_s.Item(); dataItem.testId = testId; diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/MeshTest.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/MeshTest.java index f39e7db..cdb4435 100644 --- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/MeshTest.java +++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/MeshTest.java @@ -69,6 +69,9 @@ public class MeshTest implements RsBenchBaseTest{ mTests[index].testName = Allocation.createFromString(mRS, mNames[index], Allocation.USAGE_SCRIPT); + mTests[index].debugName = RsBenchRS.createZeroTerminatedAlloc(mRS, + mNames[index], + Allocation.USAGE_SCRIPT); ScriptField_MeshTestData_s.Item dataItem = new ScriptField_MeshTestData_s.Item(); dataItem.meshNum = meshNum; diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java index c51bd82..8c67026 100644 --- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java +++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java @@ -60,7 +60,6 @@ public class RsBenchRS { mWidth = width; mHeight = height; mMode = 0; - mMaxModes = 0; mLoops = loops; mCurrentLoop = 0; mBenchmarkDimX = 1280; @@ -88,11 +87,30 @@ public class RsBenchRS { ScriptField_TestScripts_s.Item[] mIndividualTests; int mMode; - int mMaxModes; String[] mTestNames; float[] mLocalTestResults; + static Allocation createZeroTerminatedAlloc(RenderScript rs, + String str, + int usage) { + byte[] allocArray = null; + try { + allocArray = str.getBytes("UTF-8"); + byte[] allocArrayZero = new byte[allocArray.length + 1]; + System.arraycopy(allocArray, 0, allocArrayZero, 0, allocArray.length); + allocArrayZero[allocArrayZero.length - 1] = '\0'; + Allocation alloc = Allocation.createSized(rs, Element.U8(rs), + allocArrayZero.length, usage); + alloc.copyFrom(allocArrayZero); + return alloc; + } + catch (Exception e) { + throw new RSRuntimeException("Could not convert string to utf-8."); + } + + } + void appendTests(RsBenchBaseTest testSet) { ScriptField_TestScripts_s.Item[] newTests = testSet.getTests(); if (mIndividualTests != null) { @@ -119,6 +137,7 @@ public class RsBenchRS { void createTestAllocation() { int numTests = mIndividualTests.length; + mLocalTestResults = new float[numTests]; ScriptField_TestScripts_s allTests; allTests = new ScriptField_TestScripts_s(mRS, numTests); for (int i = 0; i < numTests; i ++) { @@ -239,11 +258,6 @@ public class RsBenchRS { return count; } - private void prepareTestData() { - mTestNames = new String[mMaxModes]; - mLocalTestResults = new float[mMaxModes]; - } - public void setDebugMode(int num) { mScript.invoke_setDebugMode(num); } @@ -261,8 +275,6 @@ public class RsBenchRS { mScript.set_gMaxLoops(mLoops); - prepareTestData(); - initProgramVertex(); initProgramFragment(); mScript.set_gFontSerif(Font.create(mRS, mRes, "serif", Font.Style.NORMAL, 8)); diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TextTest.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TextTest.java index ca9e660..3ca2792 100644 --- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TextTest.java +++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TextTest.java @@ -48,6 +48,9 @@ public class TextTest implements RsBenchBaseTest{ mTests[index].testName = Allocation.createFromString(mRS, mNames[index], Allocation.USAGE_SCRIPT); + mTests[index].debugName = RsBenchRS.createZeroTerminatedAlloc(mRS, + mNames[index], + Allocation.USAGE_SCRIPT); ScriptField_TextTestData_s.Item dataItem = new ScriptField_TextTestData_s.Item(); dataItem.fillNum = fillNum; diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TorusTest.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TorusTest.java index d785dc1..5c9ecd5 100644 --- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TorusTest.java +++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TorusTest.java @@ -98,6 +98,9 @@ public class TorusTest implements RsBenchBaseTest{ mTests[index].testName = Allocation.createFromString(mRS, mNames[index], Allocation.USAGE_SCRIPT); + mTests[index].debugName = RsBenchRS.createZeroTerminatedAlloc(mRS, + mNames[index], + Allocation.USAGE_SCRIPT); ScriptField_TorusTestData_s.Item dataItem = new ScriptField_TorusTestData_s.Item(); dataItem.testId = testId; diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/UiTest.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/UiTest.java index cca237e..c8b58b2 100644 --- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/UiTest.java +++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/UiTest.java @@ -82,6 +82,9 @@ public class UiTest implements RsBenchBaseTest{ mTests[index].testName = Allocation.createFromString(mRS, mNames[index], Allocation.USAGE_SCRIPT); + mTests[index].debugName = RsBenchRS.createZeroTerminatedAlloc(mRS, + mNames[index], + Allocation.USAGE_SCRIPT); ScriptField_UiTestData_s.Item dataItem = new ScriptField_UiTestData_s.Item(); dataItem.testId = testId; diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs index 2b849a2..cb15449 100644 --- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs +++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs @@ -45,6 +45,7 @@ VertexShaderInputs *gVSInputs; typedef struct TestScripts_s { rs_allocation testData; rs_allocation testName; + rs_allocation debugName; rs_script testScript; } TestScripts; TestScripts *gTestScripts; @@ -195,7 +196,8 @@ static void benchmark() { int64_t end = rsUptimeMillis(); float fps = (float)(frameCount) / ((float)(end - start)*0.001f); - rsDebug("Finishes test ", fps); + const char *testName = rsGetElementAt(gTestScripts[benchMode].debugName, 0); + rsDebug(testName, fps); gResultBuffer[benchMode] = fps; int bufferW = rsAllocationGetDimX(gRenderBufferColor); -- cgit v1.1