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 onCreate(Bundle savedInstanceState)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 onCreateOptionsMenu(Menu menu)22 public boolean onCreateOptionsMenu(Menu menu) { 23 getMenuInflater().inflate(R.menu.main, menu); 24 return true; 25 } 26 add32ByteBlocks(View view)27 public void add32ByteBlocks(View view) { 28 add32ByteBlocksNative(); 29 } 30 free32ByteBlocks(View view)31 public void free32ByteBlocks(View view) { 32 free32ByteBlocksNative(); 33 } 34 add2MByteBlocks(View view)35 public void add2MByteBlocks(View view) { 36 add2MByteBlocksNative(); 37 } 38 free2MByteBlocks(View view)39 public void free2MByteBlocks(View view) { 40 free2MByteBlocksNative(); 41 } 42 addVariableSizedBlocks(View view)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 freeVariableSizedBlocks(View view)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 forceDoubleFree(View view)59 public void forceDoubleFree(View view) { 60 forceDoubleFreeNative(); 61 } 62 add32ByteBlocksNative()63 public native void add32ByteBlocksNative(); free32ByteBlocksNative()64 public native void free32ByteBlocksNative(); add2MByteBlocksNative()65 public native void add2MByteBlocksNative(); free2MByteBlocksNative()66 public native void free2MByteBlocksNative(); addVariableSizedBlocksNative(int sizeId)67 public native void addVariableSizedBlocksNative(int sizeId); freeVariableSizedBlocksNative(int sizeId)68 public native void freeVariableSizedBlocksNative(int sizeId); forceDoubleFreeNative()69 public native void forceDoubleFreeNative(); 70 } 71