Merge "Get average value for image processing test bug#: 5566079" into ics-mr1
This commit is contained in:
@@ -41,6 +41,7 @@ import java.io.IOException;
|
|||||||
public class ImageProcessingTest extends ActivityInstrumentationTestCase2<ImageProcessingActivity> {
|
public class ImageProcessingTest extends ActivityInstrumentationTestCase2<ImageProcessingActivity> {
|
||||||
private final String TAG = "ImageProcessingTest";
|
private final String TAG = "ImageProcessingTest";
|
||||||
private final String RESULT_FILE = "image_processing_result.txt";
|
private final String RESULT_FILE = "image_processing_result.txt";
|
||||||
|
private int ITERATION = 5;
|
||||||
private ImageProcessingActivity mAct;
|
private ImageProcessingActivity mAct;
|
||||||
|
|
||||||
public ImageProcessingTest() {
|
public ImageProcessingTest() {
|
||||||
@@ -63,9 +64,8 @@ public class ImageProcessingTest extends ActivityInstrumentationTestCase2<ImageP
|
|||||||
*/
|
*/
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public void testImageProcessingBench() {
|
public void testImageProcessingBench() {
|
||||||
long t = mAct.getBenchmark();
|
long t = 0;
|
||||||
Log.v(TAG, "t = " + t);
|
long sum = 0;
|
||||||
|
|
||||||
// write result into a file
|
// write result into a file
|
||||||
File externalStorage = Environment.getExternalStorageDirectory();
|
File externalStorage = Environment.getExternalStorageDirectory();
|
||||||
if (!externalStorage.canWrite()) {
|
if (!externalStorage.canWrite()) {
|
||||||
@@ -75,10 +75,18 @@ public class ImageProcessingTest extends ActivityInstrumentationTestCase2<ImageP
|
|||||||
File resultFile = new File(externalStorage, RESULT_FILE);
|
File resultFile = new File(externalStorage, RESULT_FILE);
|
||||||
resultFile.setWritable(true, false);
|
resultFile.setWritable(true, false);
|
||||||
try {
|
try {
|
||||||
BufferedWriter results = new BufferedWriter(new FileWriter(resultFile));
|
BufferedWriter rsWriter = new BufferedWriter(new FileWriter(resultFile));
|
||||||
results.write("Renderscript frame time core: " + t + " ms");
|
|
||||||
results.close();
|
|
||||||
Log.v(TAG, "Saved results in: " + resultFile.getAbsolutePath());
|
Log.v(TAG, "Saved results in: " + resultFile.getAbsolutePath());
|
||||||
|
for (int i = 0; i < ITERATION; i++ ) {
|
||||||
|
t = mAct.getBenchmark();
|
||||||
|
sum += t;
|
||||||
|
rsWriter.write("Renderscript frame time core: " + t + " ms\n");
|
||||||
|
Log.v(TAG, "RenderScript framew time core: " + t + " ms");
|
||||||
|
}
|
||||||
|
long avgValue = sum/ITERATION;
|
||||||
|
rsWriter.write("Averge frame time: " + avgValue + " ms\n");
|
||||||
|
Log.v(TAG, "Average frame time: " + avgValue + " ms");
|
||||||
|
rsWriter.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.v(TAG, "Unable to write result file " + e.getMessage());
|
Log.v(TAG, "Unable to write result file " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user