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.app.Activity;
20import android.os.Bundle;
21import android.graphics.BitmapFactory;
22import android.graphics.Bitmap;
23import android.renderscript.RenderScript;
24import android.renderscript.Allocation;
25import android.util.Log;
26import android.widget.ImageView;
27
28public class ComputePerf extends Activity {
29    private LaunchTest mLT;
30    private Mandelbrot mMandel;
31    private RenderScript mRS;
32
33    @Override
34    protected void onCreate(Bundle savedInstanceState) {
35        super.onCreate(savedInstanceState);
36        setContentView(R.layout.main);
37
38        final int numTries = 100;
39
40        long timesXLW = 0;
41        long timesXYW = 0;
42
43        mRS = RenderScript.create(this);
44        mLT = new LaunchTest(mRS, getResources());
45        mLT.XLW();
46        mLT.XYW();
47        for (int i = 0; i < numTries; i++) {
48            timesXLW += mLT.XLW();
49            timesXYW += mLT.XYW();
50        }
51
52        timesXLW /= numTries;
53        timesXYW /= numTries;
54
55        // XLW and XYW running times should match pretty closely
56        Log.v("ComputePerf", "xlw launch test " + timesXLW + "ms");
57        Log.v("ComputePerf", "xyw launch test " + timesXYW + "ms");
58
59        mMandel = new Mandelbrot(mRS, getResources());
60        mMandel.run();
61    }
62}
63