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_launchtestxlw mScript_xlw; 27 private ScriptC_launchtestxyw mScript_xyw; 28 29 LaunchTest(RenderScript rs, Resources res) { 30 mRS = rs; 31 mScript_xlw = new ScriptC_launchtestxlw(mRS, res, R.raw.launchtestxlw); 32 mScript_xyw = new ScriptC_launchtestxyw(mRS, res, R.raw.launchtestxyw); 33 final int dim = mScript_xlw.get_dim(); 34 35 mAllocationX = Allocation.createSized(rs, Element.U8(rs), dim); 36 Type.Builder tb = new Type.Builder(rs, Element.U8(rs)); 37 tb.setX(dim); 38 tb.setY(dim); 39 mAllocationXY = Allocation.createTyped(rs, tb.create()); 40 mScript_xlw.bind_buf(mAllocationXY); 41 } 42 43 public long XLW() { 44 long t = java.lang.System.currentTimeMillis(); 45 mScript_xlw.forEach_root(mAllocationX); 46 mRS.finish(); 47 t = java.lang.System.currentTimeMillis() - t; 48 return t; 49 } 50 51 public long XYW() { 52 long t = java.lang.System.currentTimeMillis(); 53 mScript_xyw.forEach_root(mAllocationXY); 54 mRS.finish(); 55 t = java.lang.System.currentTimeMillis() - t; 56 return t; 57 } 58} 59