Home | History | Annotate | Download | only in moarram
      1 package com.android.benchmark.moarram;
      2 
      3 import android.os.Bundle;
      4 import android.app.Activity;
      5 import android.view.Menu;
      6 import android.view.View;
      7 import android.widget.RadioGroup;
      8 
      9 public class MainActivity extends Activity {
     10 
     11     @Override
     12     protected void onCreate(Bundle savedInstanceState) {
     13         super.onCreate(savedInstanceState);
     14         System.loadLibrary("moarram-32");
     15         System.loadLibrary("moarram-2M");
     16         System.loadLibrary("moarram-17_71");
     17         System.loadLibrary("moarram-doublefree");
     18         setContentView(R.layout.activity_main);
     19     }
     20 
     21     @Override
     22     public boolean onCreateOptionsMenu(Menu menu) {
     23         getMenuInflater().inflate(R.menu.main, menu);
     24         return true;
     25     }
     26 
     27     public void add32ByteBlocks(View view) {
     28         add32ByteBlocksNative();
     29     }
     30 
     31     public void free32ByteBlocks(View view) {
     32         free32ByteBlocksNative();
     33     }
     34 
     35     public void add2MByteBlocks(View view) {
     36         add2MByteBlocksNative();
     37     }
     38 
     39     public void free2MByteBlocks(View view) {
     40         free2MByteBlocksNative();
     41     }
     42 
     43     public void addVariableSizedBlocks(View view) {
     44 
     45         RadioGroup sizeGroup = (RadioGroup) findViewById(R.id.blockSize);
     46 
     47         int sizeId = sizeGroup.getCheckedRadioButtonId();
     48         addVariableSizedBlocksNative(sizeId == R.id.radio17 ? 0 : 1);
     49     }
     50 
     51     public void freeVariableSizedBlocks(View view) {
     52 
     53         RadioGroup sizeGroup = (RadioGroup) findViewById(R.id.blockSize);
     54 
     55         int sizeId = sizeGroup.getCheckedRadioButtonId();
     56         freeVariableSizedBlocksNative(sizeId == R.id.radio17 ? 0 : 1);
     57     }
     58 
     59     public void forceDoubleFree(View view) {
     60         forceDoubleFreeNative();
     61     }
     62 
     63     public native void add32ByteBlocksNative();
     64     public native void free32ByteBlocksNative();
     65     public native void add2MByteBlocksNative();
     66     public native void free2MByteBlocksNative();
     67     public native void addVariableSizedBlocksNative(int sizeId);
     68     public native void freeVariableSizedBlocksNative(int sizeId);
     69     public native void forceDoubleFreeNative();
     70 }
     71