summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJason Sams <jsams@google.com>2012-09-21 18:13:16 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-21 18:13:16 -0700
commit82c8cdabc4161763cecaa9050bd2c544cc89e283 (patch)
tree6f98ac3b696b9ce566a84109e43fb378e65a5fbc /tests
parent7546b5ff1625d80296c0cdcb09ad28e037ab7fb6 (diff)
parentb94d69a2267d2660ade79ff5e56ecb00f307c553 (diff)
downloadframeworks_base-82c8cdabc4161763cecaa9050bd2c544cc89e283.zip
frameworks_base-82c8cdabc4161763cecaa9050bd2c544cc89e283.tar.gz
frameworks_base-82c8cdabc4161763cecaa9050bd2c544cc89e283.tar.bz2
Merge "Add run all button to image processing test." into jb-mr1-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/RenderScriptTests/ImageProcessing/res/layout/main.xml5
-rw-r--r--tests/RenderScriptTests/ImageProcessing/res/values/strings.xml1
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java54
3 files changed, 53 insertions, 7 deletions
diff --git a/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml b/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml
index bd56d62..4715d6e 100644
--- a/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml
+++ b/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml
@@ -124,6 +124,11 @@
android:layout_marginRight="10sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/benchmark_all"
+ android:onClick="benchmark_all"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
diff --git a/tests/RenderScriptTests/ImageProcessing/res/values/strings.xml b/tests/RenderScriptTests/ImageProcessing/res/values/strings.xml
index cc5cc4d..a7dd165 100644
--- a/tests/RenderScriptTests/ImageProcessing/res/values/strings.xml
+++ b/tests/RenderScriptTests/ImageProcessing/res/values/strings.xml
@@ -29,5 +29,6 @@
<string name="gamma">Gamma</string>
<string name="saturation">Saturation</string>
<string name="benchmark">Benchmark</string>
+ <string name="benchmark_all">Benchmark All</string>
</resources>
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
index f5d3ee2..5311399 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
@@ -39,9 +39,21 @@ import android.view.View;
import android.util.Log;
import java.lang.Math;
+import android.os.Environment;
+import android.app.Instrumentation;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
public class ImageProcessingActivity extends Activity
implements SeekBar.OnSeekBarChangeListener {
private final String TAG = "Img";
+ private final String RESULT_FILE = "image_processing_result.csv";
+
Bitmap mBitmapIn;
Bitmap mBitmapOut;
String mTestNames[];
@@ -325,6 +337,33 @@ public class ImageProcessingActivity extends Activity
//long javaTime = javaFilter();
//mBenchmarkResult.setText("RS: " + t + " ms Java: " + javaTime + " ms");
mBenchmarkResult.setText("Result: " + t + " ms");
+ Log.v(TAG, "getBenchmark: Renderscript frame time core ms " + t);
+ }
+
+ public void benchmark_all(View v) {
+ // write result into a file
+ File externalStorage = Environment.getExternalStorageDirectory();
+ if (!externalStorage.canWrite()) {
+ Log.v(TAG, "sdcard is not writable");
+ return;
+ }
+ File resultFile = new File(externalStorage, RESULT_FILE);
+ resultFile.setWritable(true, false);
+ try {
+ BufferedWriter rsWriter = new BufferedWriter(new FileWriter(resultFile));
+ Log.v(TAG, "Saved results in: " + resultFile.getAbsolutePath());
+ for (int i = 0; i < mTestNames.length; i++ ) {
+ changeTest(i);
+ float t = getBenchmark();
+ String s = new String("" + mTestNames[i] + ", " + t);
+ rsWriter.write(s + "\n");
+ Log.v(TAG, "Test " + s + "ms\n");
+ }
+ rsWriter.close();
+ } catch (IOException e) {
+ Log.v(TAG, "Unable to write result file " + e.getMessage());
+ }
+ changeTest(0);
}
// For benchmark test
@@ -334,7 +373,7 @@ public class ImageProcessingActivity extends Activity
mTest.setupBenchmark();
long result = 0;
- Log.v(TAG, "Warming");
+ //Log.v(TAG, "Warming");
long t = java.lang.System.currentTimeMillis() + 2000;
do {
mTest.runTest();
@@ -342,17 +381,18 @@ public class ImageProcessingActivity extends Activity
} while (t > java.lang.System.currentTimeMillis());
- Log.v(TAG, "Benchmarking");
+ //Log.v(TAG, "Benchmarking");
+ int ct = 0;
t = java.lang.System.currentTimeMillis();
- for (int i=0; i<10; i++) {
+ do {
mTest.runTest();
- }
- mTest.finish();
+ mTest.finish();
+ ct++;
+ } while ((t+5000) > java.lang.System.currentTimeMillis());
t = java.lang.System.currentTimeMillis() - t;
float ft = (float)t;
- ft /= 10;
+ ft /= ct;
- Log.v(TAG, "getBenchmark: Renderscript frame time core ms " + ft);
mTest.exitBenchmark();
mDoingBenchmark = false;