Merge "Run ComputePerf multiple times."
This commit is contained in:
committed by
Android (Google) Code Review
commit
03cbb97e4e
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2011 The Android Open Source Project
|
* Copyright (C) 2011-2012 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -22,10 +22,10 @@ import android.graphics.BitmapFactory;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.renderscript.RenderScript;
|
import android.renderscript.RenderScript;
|
||||||
import android.renderscript.Allocation;
|
import android.renderscript.Allocation;
|
||||||
|
import android.util.Log;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
public class ComputePerf extends Activity {
|
public class ComputePerf extends Activity {
|
||||||
|
|
||||||
private LaunchTest mLT;
|
private LaunchTest mLT;
|
||||||
private Mandelbrot mMandel;
|
private Mandelbrot mMandel;
|
||||||
private RenderScript mRS;
|
private RenderScript mRS;
|
||||||
@@ -35,14 +35,28 @@ public class ComputePerf extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
|
final int numTries = 100;
|
||||||
|
|
||||||
|
long timesXLW = 0;
|
||||||
|
long timesXYW = 0;
|
||||||
|
|
||||||
mRS = RenderScript.create(this);
|
mRS = RenderScript.create(this);
|
||||||
mLT = new LaunchTest(mRS, getResources());
|
mLT = new LaunchTest(mRS, getResources());
|
||||||
mLT.run();
|
mLT.XLW();
|
||||||
mLT.run();
|
mLT.XYW();
|
||||||
|
for (int i = 0; i < numTries; i++) {
|
||||||
|
timesXLW += mLT.XLW();
|
||||||
|
timesXYW += mLT.XYW();
|
||||||
|
}
|
||||||
|
|
||||||
|
timesXLW /= numTries;
|
||||||
|
timesXYW /= numTries;
|
||||||
|
|
||||||
|
// XLW and XYW running times should match pretty closely
|
||||||
|
Log.v("ComputePerf", "xlw launch test " + timesXLW + "ms");
|
||||||
|
Log.v("ComputePerf", "xyw launch test " + timesXYW + "ms");
|
||||||
|
|
||||||
mMandel = new Mandelbrot(mRS, getResources());
|
mMandel = new Mandelbrot(mRS, getResources());
|
||||||
mMandel.run();
|
mMandel.run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2011 The Android Open Source Project
|
* Copyright (C) 2011-2012 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -19,7 +19,7 @@ package com.example.android.rs.computeperf;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.renderscript.*;
|
import android.renderscript.*;
|
||||||
|
|
||||||
public class LaunchTest implements Runnable {
|
public class LaunchTest {
|
||||||
private RenderScript mRS;
|
private RenderScript mRS;
|
||||||
private Allocation mAllocationX;
|
private Allocation mAllocationX;
|
||||||
private Allocation mAllocationXY;
|
private Allocation mAllocationXY;
|
||||||
@@ -40,18 +40,19 @@ public class LaunchTest implements Runnable {
|
|||||||
mScript_xlw.bind_buf(mAllocationXY);
|
mScript_xlw.bind_buf(mAllocationXY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public long XLW() {
|
||||||
long t = java.lang.System.currentTimeMillis();
|
long t = java.lang.System.currentTimeMillis();
|
||||||
mScript_xlw.forEach_root(mAllocationX);
|
mScript_xlw.forEach_root(mAllocationX);
|
||||||
mRS.finish();
|
mRS.finish();
|
||||||
t = java.lang.System.currentTimeMillis() - t;
|
t = java.lang.System.currentTimeMillis() - t;
|
||||||
android.util.Log.v("ComputePerf", "xlw launch test ms " + t);
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
t = java.lang.System.currentTimeMillis();
|
public long XYW() {
|
||||||
|
long t = java.lang.System.currentTimeMillis();
|
||||||
mScript_xyw.forEach_root(mAllocationXY);
|
mScript_xyw.forEach_root(mAllocationXY);
|
||||||
mRS.finish();
|
mRS.finish();
|
||||||
t = java.lang.System.currentTimeMillis() - t;
|
t = java.lang.System.currentTimeMillis() - t;
|
||||||
android.util.Log.v("ComputePerf", "xyw launch test ms " + t);
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user