Merge "Integrate ImageProcessing test into test framework http://b/issue?id=5274365 Change-Id: I7949b4114dcab17d895d04755df5df2bd5a576a3"
This commit is contained in:
@@ -17,7 +17,9 @@
|
|||||||
LOCAL_PATH := $(call my-dir)
|
LOCAL_PATH := $(call my-dir)
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_MODULE_TAGS := optional
|
LOCAL_MODULE_TAGS := tests
|
||||||
|
|
||||||
|
LOCAL_JAVA_LIBRARIES := android.test.runner
|
||||||
|
|
||||||
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
|
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
|
||||||
$(call all-renderscript-files-under, src)
|
$(call all-renderscript-files-under, src)
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.android.rs.image">
|
package="com.android.rs.image">
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-sdk android:minSdkVersion="11" />
|
<uses-sdk android:minSdkVersion="11" />
|
||||||
<application android:label="Image Processing"
|
<application android:label="Image Processing"
|
||||||
android:hardwareAccelerated="true">
|
android:hardwareAccelerated="true">
|
||||||
|
<uses-library android:name="android.test.runner" />
|
||||||
<activity android:name="ImageProcessingActivity">
|
<activity android:name="ImageProcessingActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
@@ -13,4 +14,9 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
<instrumentation android:name=".ImageProcessingTestRunner"
|
||||||
|
android:targetPackage="com.android.rs.image"
|
||||||
|
android:label="Test runner for Image Processing Benchmark Test"
|
||||||
|
/>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -33,11 +33,13 @@ import android.widget.ImageView;
|
|||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.util.Log;
|
||||||
import java.lang.Math;
|
import java.lang.Math;
|
||||||
|
|
||||||
public class ImageProcessingActivity extends Activity
|
public class ImageProcessingActivity extends Activity
|
||||||
implements SurfaceHolder.Callback,
|
implements SurfaceHolder.Callback,
|
||||||
SeekBar.OnSeekBarChangeListener {
|
SeekBar.OnSeekBarChangeListener {
|
||||||
|
private final String TAG = "Img";
|
||||||
private Bitmap mBitmapIn;
|
private Bitmap mBitmapIn;
|
||||||
private Bitmap mBitmapOut;
|
private Bitmap mBitmapOut;
|
||||||
private ScriptC_threshold mScript;
|
private ScriptC_threshold mScript;
|
||||||
@@ -268,7 +270,15 @@ public class ImageProcessingActivity extends Activity
|
|||||||
|
|
||||||
// button hook
|
// button hook
|
||||||
public void benchmark(View v) {
|
public void benchmark(View v) {
|
||||||
android.util.Log.v("Img", "Benchmarking");
|
long t = getBenchmark();
|
||||||
|
//long javaTime = javaFilter();
|
||||||
|
//mBenchmarkResult.setText("RS: " + t + " ms Java: " + javaTime + " ms");
|
||||||
|
mBenchmarkResult.setText("Result: " + t + " ms");
|
||||||
|
}
|
||||||
|
|
||||||
|
// For benchmark test
|
||||||
|
public long getBenchmark() {
|
||||||
|
Log.v(TAG, "Benchmarking");
|
||||||
int oldRadius = mRadius;
|
int oldRadius = mRadius;
|
||||||
mRadius = MAX_RADIUS;
|
mRadius = MAX_RADIUS;
|
||||||
mScript.set_radius(mRadius);
|
mScript.set_radius(mRadius);
|
||||||
@@ -279,16 +289,12 @@ public class ImageProcessingActivity extends Activity
|
|||||||
mOutPixelsAllocation.copyTo(mBitmapOut);
|
mOutPixelsAllocation.copyTo(mBitmapOut);
|
||||||
|
|
||||||
t = java.lang.System.currentTimeMillis() - t;
|
t = java.lang.System.currentTimeMillis() - t;
|
||||||
android.util.Log.v("Img", "Renderscript frame time core ms " + t);
|
Log.v(TAG, "getBenchmark: Renderscript frame time core ms " + t);
|
||||||
|
|
||||||
//long javaTime = javaFilter();
|
|
||||||
//mBenchmarkResult.setText("RS: " + t + " ms Java: " + javaTime + " ms");
|
|
||||||
mBenchmarkResult.setText("Result: " + t + " ms");
|
|
||||||
|
|
||||||
mRadius = oldRadius;
|
mRadius = oldRadius;
|
||||||
mScript.set_radius(mRadius);
|
mScript.set_radius(mRadius);
|
||||||
|
|
||||||
mScript.invoke_filter();
|
mScript.invoke_filter();
|
||||||
mOutPixelsAllocation.copyTo(mBitmapOut);
|
mOutPixelsAllocation.copyTo(mBitmapOut);
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2011 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.rs.image;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.app.Instrumentation;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ImageProcessing benchmark test.
|
||||||
|
* To run the test, please use command
|
||||||
|
*
|
||||||
|
* adb shell am instrument -w com.android.rs.image/.ImageProcessingTestRunner
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ImageProcessingTest extends ActivityInstrumentationTestCase2<ImageProcessingActivity> {
|
||||||
|
private final String TAG = "ImageProcessingTest";
|
||||||
|
private final String RESULT_FILE = "image_processing_result.txt";
|
||||||
|
private ImageProcessingActivity mAct;
|
||||||
|
|
||||||
|
public ImageProcessingTest() {
|
||||||
|
super(ImageProcessingActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
mAct = getActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ImageProcessing benchmark test
|
||||||
|
*/
|
||||||
|
@LargeTest
|
||||||
|
public void testImageProcessingBench() {
|
||||||
|
long t = mAct.getBenchmark();
|
||||||
|
Log.v(TAG, "t = " + t);
|
||||||
|
|
||||||
|
// 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 results = new BufferedWriter(new FileWriter(resultFile));
|
||||||
|
results.write("Renderscript frame time core: " + t + " ms");
|
||||||
|
results.close();
|
||||||
|
Log.v(TAG, "Saved results in: " + resultFile.getAbsolutePath());
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.v(TAG, "Unable to write result file " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2011 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.rs.image;
|
||||||
|
|
||||||
|
import com.android.rs.image.ImageProcessingTest;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.test.InstrumentationTestRunner;
|
||||||
|
import android.test.InstrumentationTestSuite;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the ImageProcessing benchmark test
|
||||||
|
* adb shell am instrument -w com.android.rs.image/.ImageProcessingTestRunner
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ImageProcessingTestRunner extends InstrumentationTestRunner {
|
||||||
|
@Override
|
||||||
|
public TestSuite getAllTests() {
|
||||||
|
TestSuite suite = new InstrumentationTestSuite(this);
|
||||||
|
suite.addTestSuite(ImageProcessingTest.class);
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user