1/* 2 * Copyright (C) 2011-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 17package com.example.android.rs.computeperf; 18 19import android.content.res.Resources; 20import android.renderscript.*; 21 22public class LaunchTest { 23 private RenderScript mRS; 24 private Allocation mAllocationX; 25 private Allocation mAllocationXY; 26 private ScriptC_launchtest mScript; 27 28 LaunchTest(RenderScript rs, Resources res) { 29 mRS = rs; 30 mScript = new ScriptC_launchtest(mRS); 31 final int dim = mScript.get_dim(); 32 33 mAllocationX = Allocation.createSized(rs, Element.U8(rs), dim); 34 Type.Builder tb = new Type.Builder(rs, Element.U8(rs)); 35 tb.setX(dim); 36 tb.setY(dim); 37 mAllocationXY = Allocation.createTyped(rs, tb.create()); 38 mScript.set_gBuf(mAllocationXY); 39 } 40 41 public long XLW() { 42 long t = java.lang.System.currentTimeMillis(); 43 mScript.forEach_k_x(mAllocationX); 44 mRS.finish(); 45 t = java.lang.System.currentTimeMillis() - t; 46 return t; 47 } 48 49 public long XYW() { 50 long t = java.lang.System.currentTimeMillis(); 51 mScript.forEach_k_xy(mAllocationXY); 52 mRS.finish(); 53 t = java.lang.System.currentTimeMillis() - t; 54 return t; 55 } 56} 57