Skip to content

Commit 31bc7f9

Browse files
stephenhinesAndroid (Google) Code Review
authored andcommitted
Merge "Initial version of Renderscript Compute Benchmark" into jb-mr1-dev
2 parents 9196c9a + 000dc53 commit 31bc7f9

File tree

6 files changed

+572
-0
lines changed

6 files changed

+572
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Copyright (C) 2012 The Android Open Source Project
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
LOCAL_PATH := $(call my-dir)
18+
include $(CLEAR_VARS)
19+
20+
LOCAL_MODULE_TAGS := tests
21+
22+
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
23+
$(call all-renderscript-files-under, src)
24+
25+
LOCAL_PACKAGE_NAME := RsComputeBenchmark
26+
27+
include $(BUILD_PACKAGE)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2012 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
18+
package="com.example.android.rs.computebench">
19+
20+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
21+
<uses-sdk android:minSdkVersion="17" />
22+
<application android:label="_RS_Compute_Bench">
23+
<activity android:name="ComputeBench">
24+
<intent-filter>
25+
<action android:name="android.intent.action.MAIN" />
26+
<category android:name="android.intent.category.LAUNCHER" />
27+
</intent-filter>
28+
</activity>
29+
</application>
30+
</manifest>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2012 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:layout_width="match_parent"
19+
android:layout_height="match_parent">
20+
21+
<ImageView
22+
android:id="@+id/displayin"
23+
android:layout_width="320dip"
24+
android:layout_height="266dip" />
25+
26+
<ImageView
27+
android:id="@+id/displayout"
28+
android:layout_width="320dip"
29+
android:layout_height="266dip" />
30+
31+
</LinearLayout>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.android.rs.computebench;
18+
import android.content.Context;
19+
import android.content.res.Resources;
20+
import android.renderscript.*;
21+
22+
public class Benchmark implements Runnable {
23+
private final RenderScript mRS;
24+
private ScriptC_compute_benchmark mScript;
25+
26+
public Benchmark(RenderScript rs, Resources res) {
27+
mRS = rs;
28+
mScript = new ScriptC_compute_benchmark(mRS, res, R.raw.compute_benchmark);
29+
}
30+
31+
public void run() {
32+
long t = java.lang.System.currentTimeMillis();
33+
mScript.invoke_bench();
34+
mRS.finish();
35+
t = java.lang.System.currentTimeMillis() - t;
36+
android.util.Log.v("ComputeBench", "Total benchmark took " + t + " ms");
37+
}
38+
39+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.android.rs.computebench;
18+
19+
import android.app.Activity;
20+
import android.os.Bundle;
21+
import android.renderscript.RenderScript;
22+
23+
public class ComputeBench extends Activity {
24+
private RenderScript mRS;
25+
private Benchmark mBenchmark;
26+
27+
@Override
28+
protected void onCreate(Bundle savedInstanceState) {
29+
super.onCreate(savedInstanceState);
30+
setContentView(R.layout.main);
31+
32+
mRS = RenderScript.create(this);
33+
34+
mBenchmark = new Benchmark(mRS, getResources());
35+
mBenchmark.run();
36+
}
37+
}

0 commit comments

Comments
 (0)