diff options
author | Jason Sams <jsams@google.com> | 2012-09-21 18:13:16 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-21 18:13:16 -0700 |
commit | 82c8cdabc4161763cecaa9050bd2c544cc89e283 (patch) | |
tree | 6f98ac3b696b9ce566a84109e43fb378e65a5fbc /tests/RenderScriptTests/ImageProcessing/src/com/android/rs | |
parent | 7546b5ff1625d80296c0cdcb09ad28e037ab7fb6 (diff) | |
parent | b94d69a2267d2660ade79ff5e56ecb00f307c553 (diff) | |
download | frameworks_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/RenderScriptTests/ImageProcessing/src/com/android/rs')
-rw-r--r-- | tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java | 54 |
1 files changed, 47 insertions, 7 deletions
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; |