FileDocCategorySizeDatePackage
RsBench.javaAPI DocAndroid 5.1 API4915Thu Mar 12 22:22:44 GMT 2015com.android.perftest

RsBench

public class RsBench extends android.app.Activity

Fields Summary
private final String
TAG
public RsBenchView
mView
Constructors Summary
Methods Summary
public voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);
        int iterations = 0;
        Intent intent = getIntent();
        Uri uri = intent.getData();
        if (uri != null) {
            // when lauched from instrumentation
            String scheme = uri.getScheme();
            if ("iterations".equals(scheme)) {
                iterations = Integer.parseInt(uri.getSchemeSpecificPart());
            }
        }
        // Create our Preview view and set it as the content of our
        // Activity
        mView = new RsBenchView(this);
        setContentView(mView);
        mView.setLoops(iterations);
    
public booleanonCreateOptionsMenu(android.view.Menu menu)

        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.loader_menu, menu);
        return true;
    
public booleanonOptionsItemSelected(android.view.MenuItem item)

        // Handle item selection
        switch (item.getItemId()) {
            case R.id.benchmark_all:
                mView.setBenchmarkMode(-1);
                mView.suspendRendering(false);
                return true;
            case R.id.benchmark_one:
                mView.suspendRendering(true);
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle("Pick a Test");
                builder.setItems(mView.getTestNames(),
                                 new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {
                        Toast.makeText(getApplicationContext(),
                                       "Starting to benchmark: " + mView.getTestNames()[item],
                                       Toast.LENGTH_SHORT).show();
                        mView.setBenchmarkMode(item);
                        mView.suspendRendering(false);
                    }
                });
                builder.show();
                return true;
            case R.id.debug_mode:
                mView.suspendRendering(true);
                AlertDialog.Builder debugBuilder = new AlertDialog.Builder(this);
                debugBuilder.setTitle("Pick a Test");
                debugBuilder.setItems(mView.getTestNames(),
                                 new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {
                        Toast.makeText(getApplicationContext(),
                                       "Switching to: " + mView.getTestNames()[item],
                                       Toast.LENGTH_SHORT).show();
                        mView.setDebugMode(item);
                        mView.suspendRendering(false);
                    }
                });
                debugBuilder.show();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    
protected voidonPause()

        // Ideally a game should implement onResume() and onPause()
        // to take appropriate action when the activity loses focus
        super.onPause();
        mView.pause();
    
protected voidonResume()

        // Ideally a game should implement onResume() and onPause()
        // to take appropriate action when the activity loses focus
        super.onResume();
        mView.resume();