summaryrefslogtreecommitdiff
path: root/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/MainActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/MainActivity.java')
-rw-r--r--BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/MainActivity.java299
1 files changed, 205 insertions, 94 deletions
diff --git a/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/MainActivity.java b/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/MainActivity.java
index ce191b7..1c00b44 100644
--- a/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/MainActivity.java
+++ b/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/MainActivity.java
@@ -32,6 +32,8 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
+import android.view.WindowManager;
+import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
@@ -56,7 +58,9 @@ import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
@@ -65,24 +69,21 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private Button mStartButton;
private Button mStartAutoButton;
- private Button mSaveButton;
+ private Button mChartButton;
private Button mInfo;
private Button mShowHideDispay;
- //private ListView mListView;
private TextView mDisplayDetails;
private static TextView mToolbarRepeatIndicator;
- //public ArrayAdapter listAdapter;
- ProgressDialog progressDialog;
+ public ProgressDialog progressDialog;
private String mSelectedTest = "";
private String mSelectedClassTest = "";
- private String autoTestFileNameIdentifier = "Default";
+ public static String autoTestFileNameIdentifier = "Default";
private String mTestResult = "";
private String mAllTestsResult = "";
public static String PACKAGE_NAME;
private List<String> mAllTests;
private ArrayList selectedClassTests;
- final String[] classNameTestItems = new String[15];
private static String KEY_REPEAT_NUMBER = "repeat-number";
private static String KEY_FILE_FORMAT = "file-format";
@@ -117,16 +118,19 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private TaskCanceler taskCanceler;
private Handler handler = new Handler();
- public static long startTotalTime = 0;
- public static long endTotalTime = 0;
+ public static long elapsedTotalTime = 0;
public static String runningTests = "";
public static int APP_UID;
public static String mStep;
public static String mFrom;
+ public static String mSelectedTxt;
+ public static String GRAPHICS_ELAPSED_TIME = "graphics_elapsed_time";
+ public static String GRAPHICS_ROUND = "graphics_round";
+ public static Map<String, String> mapTimes = new HashMap<String, String>();
//*************************
private int count;
@@ -135,16 +139,48 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
int pixMin;
public GridView mListViewGrid;
+
+ public static final Lock LOCK = new Lock();
+
+ final String[] classNameTestItems = {"Test1",
+ "Test2",
+ "Test3",
+ "Test4",
+ "Test5",
+ "Test6",
+ "Test7",
+ "Test8",
+ "Test9",
+ "Test10",
+ "Test11",
+ "Test12",
+ "Test13",
+ "Test14",
+ "Test15",
+ "Test16",
+ "Test17",
+ "Test18",
+ "Test19",
+ "Test20",
+ "Test21",
+ "Test22",
+ "Test23",
+ "Test24",
+ "Test25"};
+
//**********************************************************************************************
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
+ //Prevent screen off cause this will interrupt the some of tests running in own activity(GPU tests)
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+
mContext = getApplicationContext();
mActivity = this;
- APP_UID = android.os.Process.myUid();
+ APP_UID = android.os.Process.myUid();
PACKAGE_NAME = getApplicationContext().getPackageName();
mStartButton = (Button) findViewById(R.id.startButton);
@@ -162,6 +198,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// Sets the Toolbar to act as the ActionBar for this Activity window.
// Make sure the toolbar exists in the activity and is not null
setSupportActionBar(toolbar);
+ getSupportActionBar().setTitle(" Benchmark Framework");
+ //getSupportActionBar().setSubtitle(" Linaro Open source benchmarks");
+ getSupportActionBar().setIcon(R.drawable.lmg_logo_toolbar);
mToolbarRepeatIndicator = (TextView) findViewById(R.id.toolbar_repeat_indicator);
mToolbarRepeatIndicator.setText(" "+mRepeatNumber+" ");
@@ -169,8 +208,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
mStartAutoButton = (Button) findViewById(R.id.startAutoButton);
mStartAutoButton.setOnClickListener(this);
- mSaveButton = (Button) findViewById(R.id.saveButton);
- mSaveButton.setOnClickListener(this);
+ mChartButton = (Button) findViewById(R.id.chartButton);
+ mChartButton.setOnClickListener(this);
mInfo = (Button) findViewById(R.id.infoButton);
mInfo.setOnClickListener(this);
@@ -204,6 +243,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(mActivity, Results.class);
+ //Intent i = new Intent(mActivity, Chart.class);
startActivity(i);
return true;
}
@@ -215,42 +255,31 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
SAVE_DATA_PATH = getFilesDir() + "/download";
TEMP_PATH = EXECUTABLE_PATH + "/temp";
- classNameTestItems[0] = "Test1";
- classNameTestItems[1] = "Test2";
- classNameTestItems[2] = "Test3";
- classNameTestItems[3] = "Test4";
- classNameTestItems[4] = "Test5";
- classNameTestItems[5] = "Test6";
- classNameTestItems[6] = "Test7";
- classNameTestItems[7] = "Test8";
-
- classNameTestItems[8] = "Test9";
- classNameTestItems[9] = "Test10";
- classNameTestItems[10] = "Test11";
- classNameTestItems[11] = "Test12";
- classNameTestItems[12] = "Test13";
- classNameTestItems[13] = "Test14";
- classNameTestItems[14] = "Test15";
-
-
- String[] displayNames = new String[15];
- displayNames[0] = "MemSpeed";
- displayNames[1] = "RandMem";
- displayNames[2] = "Linaro-Libc-Bench";
- displayNames[3] = "Linaro-StringBench";
- displayNames[4] = "Linaro-Harness";
- displayNames[5] = "Linaro-Dhrystone";
- displayNames[6] = "Iozone";
- displayNames[7] = "Bonnie++";
-
- displayNames[8] = "Algorithm(ART)";
- displayNames[9] = "BMsGame(ART)";
- displayNames[10] = "Caffeine(ART)";
- displayNames[11] = "Jit-aot(ART)";
- displayNames[12] = "Math(ART)";
- displayNames[13] = "Micro(ART)";
- displayNames[14] = "Stanford(ART)";
-
+ final String[] displayNames = {"MemSpeed",
+ "RandMem",
+ "Linaro-Libc-Bench",
+ "Linaro-StringBench",
+ "Linaro-Harness",
+ "Linaro-Dhrystone",
+ "Iozone",
+ "Bonnie++",
+ "Algorithm(ART)",
+ "BMsGame(ART)",
+ "Caffeine(ART)",
+ "Jit-out(ART)",
+ "Math(ART)",
+ "Micro(ART)",
+ "Stanford(ART)",
+ "DrawArc(GPU)",
+ "DrawCircle2(GPU)",
+ "DrawImage(GPU)",
+ "DrawRect(GPU)",
+ "DrawText(GPU)",
+ "DrawCircle(GPU)",
+ "Kubench(GPU)",
+ "Nehe08(GPU)",
+ "Nehe16(GPU)",
+ "TeapotES(GPU)"};
//*******************GridView*******************
@@ -265,9 +294,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
IS_SHELL_CONTROL = false;
//Check if shell control is used for tests
-
//This fix issue with NullPointer on mListViewGrid(invoke isShellControl() when mListViewGrid layout is already inflate)
-
mListViewGrid.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@SuppressLint("NewApi")
@Override
@@ -293,6 +320,45 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// put your code here...
}
+
+ //**********************************************************************************************
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ switch(requestCode) {
+ case (100) : {
+ if (resultCode == Activity.RESULT_OK) {
+ // TODO Extract the data returned from the child Activity.
+ BaseBenchmark.elapsedFromActivityTest = data.getLongExtra(MainActivity. GRAPHICS_ELAPSED_TIME,0);
+ BaseBenchmark.mRound = data.getIntExtra(MainActivity.GRAPHICS_ROUND,0);
+ Log.i(TAG,"elapsed from activity test:" + BaseBenchmark.elapsedFromActivityTest);
+ synchronized (MainActivity.LOCK) {
+ MainActivity.LOCK.setCondition(true);
+ MainActivity.LOCK.notifyAll();
+ }
+
+ }
+ if (resultCode == Activity.RESULT_CANCELED) {
+ Log.i(TAG,"RESULT_CANCELED");
+
+ //Need to set isCanceled flag here
+ isCanceled = true;
+
+ //Simulate click on calcel button
+ progressDialog.show();
+ progressDialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick();
+
+ synchronized (MainActivity.LOCK) {
+ MainActivity.LOCK.setCondition(true);
+ MainActivity.LOCK.notifyAll();
+ }
+
+ }
+ break;
+ }
+ }
+ }
+
//**********************************************************************************************
//Load benchmarks libraries when benchmark test is integrated as (*.so)
//**********************************************************************************************
@@ -310,7 +376,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
@Override
public void onClick(View v) {
- Log.i(TAG,"numberOfCheckedTests: " + numberOfCheckedTests);
+ Log.i(TAG, "numberOfCheckedTests: " + numberOfCheckedTests);
if (v.getId() == R.id.startButton && numberOfCheckedTests > 0) {
isAuto = false;
@@ -328,10 +394,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} else if (v.getId() == R.id.startButton && numberOfCheckedTests == 0) {
Toast.makeText(v.getContext(), "Please select test...",
Toast.LENGTH_SHORT).show();
- } else if (v.getId() == R.id.saveButton && testDone == 1) {
- saveUIResultToFile();
- } else if (v.getId() == R.id.saveButton && testDone == 0) {
- Toast.makeText(v.getContext(), "No results for save",
+ } else if (v.getId() == R.id.chartButton && testDone == 1) {
+ //saveUIResultToFile();
+ Intent i = new Intent(mActivity, Chart.class);
+ startActivity(i);
+ } else if (v.getId() == R.id.chartButton && testDone == 0) {
+ Toast.makeText(v.getContext(), "No charts to show",
Toast.LENGTH_SHORT).show();
} else if (v.getId() == R.id.startAutoButton) {
isAuto = true;
@@ -341,7 +409,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} else if (v.getId() == R.id.infoButton) {
String info = "[RUN TEST]: <font color=\"#6A996A\">Run selected tests</font><br><br> " +
"[RUN AUTO]: <font color=\"#6A996A\">Run all tests in row and save results to file automatically</font><br><br> " +
- "[SAVE]: <font color=\"#6A996A\">Save result shown on UI (display)</font><br><br> " +
+ "[CHART]: <font color=\"#6A996A\">Create chart for executed tests</font><br><br> " +
"[Settings]: <br> - <font color=\"#6A996A\">Allow to control tests repeatability</font>" +
"<br><br> - <font color=\"#6A996A\">Clear Data</font>" +
"<br><br> - <font color=\"#6A996A\">File format</font>"+
@@ -543,12 +611,16 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
public void runTests(int timesToRun) {
nextTestIndex = 0;
allTestsCount = 0;
+ elapsedTotalTime = 0;
mAllTests = new ArrayList<String>();
selectedClassTests = new ArrayList<String>();
mAllTestsResult = "";
selectedClassTests.clear();
mAllTests.clear();
+ //Clear chart data
+ mapTimes.clear();
+
//HTML BEGIN
//Clear html string
if(fileFormatFromSettings.equals("html")) {
@@ -557,9 +629,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
//HTML END
- //Get total start time from here
- startTotalTime = System.currentTimeMillis();
- //Clear summary string
runningTests = "";
//reset cancel flag
@@ -895,8 +964,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
-
-
//**********************************************************************************************
//Run tests in shell control
//**********************************************************************************************
@@ -939,18 +1006,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
int mActivePosition = 0;
-
+ //Do not need to remove checks in shell mode so commented!!!
+ /*
for (String className : classNameTestItems) {
- for (String selected : testsFromShell) {
- if (className.equals(selected)) {
- //Click on the current test
- mGridViewAdapter.removeCheckAtPosition(mActivePosition, mListViewGrid);
- }
-
- }
+ mGridViewAdapter.removeCheckAtPosition(mActivePosition, mListViewGrid);
mActivePosition++;
}
-
+ */
mActivePosition = 0;
@@ -960,7 +1022,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
for (String selected : testsFromShell) {
if (className.equals(selected)) {
//Click on the current test
- mGridViewAdapter.performItemClick(mActivePosition,mListViewGrid);
+ testselection[mActivePosition] = true;
+ //mGridViewAdapter.performItemClick(mActivePosition, mListViewGrid);
}
}
@@ -1128,9 +1191,16 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
@Override
protected String doInBackground(String... params) {
+ //Log.i(TAG,"isCanceled " + isCanceled);
+
+ //if tests are canceled just return
+ if(isCanceled) return "";
+
+
//In BaseBenchmark clear() method will try "STEP_FROM" replacement again to be sure it will be done on one of both replace places
mStep = Integer.toString(stepN);
mFrom = Integer.toString(repeatN);
+ mSelectedTxt = selectedTest;
publishProgress(selectedTest, selectedClassTest, Integer.toString(stepN), Integer.toString(repeatN));
@@ -1154,7 +1224,23 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} catch (Exception e) {
e.printStackTrace();
resp = e.getMessage();
+ //Get what we can from the output
+ if(fileFormatFromSettings.equals("html")) {
+ HtmlUtil.addTemplateExecute();
+ HtmlUtil.replaceHtmlTag("EXECUTE", "");
+ HtmlUtil.addTemplateParagraph();
+ HtmlUtil.replaceHtmlTag("BODY", Interceptor.outputTxt);
+ Interceptor.clear();
+ HtmlUtil.addTemplateEnd();
+ }
+
+ mTestResult = Interceptor.outputTxt;
+ mAllTestsResult = mAllTestsResult + "\n\n" + mTestResult;
+
+ //Let's call GC
+ System.gc();
}
+
return selectedClassTest;
}
@@ -1188,21 +1274,21 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
if (result.equals(endTest) && endTestCounter == 0 && !isCanceled) { //if last one is finished and counter is 0 and is not Canceled
- //Get total end time from here
- endTotalTime = System.currentTimeMillis();
- double totalTime = (double) (endTotalTime - startTotalTime) / 1000;
-
+ //Get total time at the end
+ double totalTime = (double) (elapsedTotalTime) / 1000;
//Inform shell that tests are done
writeToSocketFile("isFinished", "1");
//Set some info to shell about test status...where results are saved
- writeToSocketFile("info", "Save result to: " + autoTestFile.getAbsolutePath());
+ if(autoTestFile!=null) {
+ writeToSocketFile("info", "Save result to: " + autoTestFile.getAbsolutePath());
+ }
displayResult(mAllTestsResult);//UI display
if(fileFormatFromSettings.equals("html")){
HtmlUtil.addTemplateSummary();
- HtmlUtil.replaceHtmlTag("TOTAL_TIME", String.format("%5.1f", totalTime) + " seconds");
+ HtmlUtil.replaceHtmlTag("TOTAL_TIME", String.format("%5.4f", totalTime) + " seconds");
if(!IS_SHELL_CONTROL) {
HtmlUtil.replaceHtmlTag("REPEAT", mRepeatNumber + " time(s)");
}else{
@@ -1224,7 +1310,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
//Decrement numberOfCheckedTests(need that because test is auto checked previously)
if(isAuto){
- numberOfCheckedTests = 0;
+ //numberOfCheckedTests = 0;
}
Log.i(TAG, "selectedTest:" + selectedTest);
@@ -1319,20 +1405,25 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
});
- progressDialog.show();
+
+ String testNumber = selectedClassTest.replace("Test", "");
+ if(!(Integer.parseInt(testNumber) >=16 && Integer.parseInt(testNumber) <=25)) {
+ progressDialog.show();
+ }
if (isAuto) {
int mActivePosition = 0;
-
- //Do remove checks here
+ //Do remove all checks here
for (String className : classNameTestItems) {
- if (className.equals(text[1])) {
- //Click on the current test
- mGridViewAdapter.removeCheckAtPosition(mActivePosition, mListViewGrid);
- }
+ //mGridViewAdapter.removeCheckAtPosition(mActivePosition, mListViewGrid);
+
+ if(testselection[mActivePosition] == true){
+ testselection[mActivePosition] = false;
+ numberOfCheckedTests--;
+ }
mActivePosition++;
}
@@ -1344,7 +1435,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
for (String className : classNameTestItems) {
if (className.equals(text[1])) {
//Click on the current test
- mGridViewAdapter.performItemClick(mActivePosition,mListViewGrid);
+ testselection[mActivePosition] = true;
+ numberOfCheckedTests++;
+ //mGridViewAdapter.performItemClick(mActivePosition,mListViewGrid);
}
mActivePosition++;
@@ -1389,21 +1482,21 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
public View getView(int position, View convertView, ViewGroup parent) {
+ //Log.i(TAG,"getView_position:" +position);
+
ViewHolder holder;
if (convertView == null) {
+ //Log.i(TAG,"getView_position_null:" +position);
holder = new ViewHolder();
convertView = mInflater.inflate(
R.layout.listview, null);
holder.textview = (TextView) convertView.findViewById(R.id.itemText);
holder.checkbox = (CheckBox) convertView.findViewById(R.id.itemCheckBox);
- //holder.textview.setText(testsList[position]);
- //holder.textview.setTextSize(getPixels(pixMin));
-
convertView.setTag(holder);
- //convertView.setBackgroundResource(R.drawable.grid_items_border);
}
else {
+ //Log.i(TAG,"getView_position_not_null:" +position);
holder = (ViewHolder) convertView.getTag();
}
holder.checkbox.setId(position);
@@ -1441,12 +1534,16 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
public void removeCheckAtPosition(int i, GridView gr) {
- //for(int i = 0; i < getCount(); i++) {
+ //It is needed to check the max index used in getView method(because max index can be smaller than count of gridview elements)
+ //So catch is used to prevent from crash when i is greater than max index used in getView
+ try {
+ //Log.i(TAG, "position:" + i);
+
ViewGroup gridChild = (ViewGroup) gr.getChildAt(i);
int childSize = gridChild.getChildCount();
- for(int k = 0; k < childSize; k++) {
- if( gridChild.getChildAt(k) instanceof CheckBox ) {
- CheckBox cb = (CheckBox)gridChild.getChildAt(k);
+ for (int k = 0; k < childSize; k++) {
+ if (gridChild.getChildAt(k) instanceof CheckBox) {
+ CheckBox cb = (CheckBox) gridChild.getChildAt(k);
//Log.i(TAG,""+i);
if (testselection[i]) {
cb.setChecked(false);
@@ -1457,7 +1554,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
}
- //}
+ }catch(Exception e){
+ Log.i(TAG, "(Expected error):removeCheckAtPosition:" + e.toString());
+ }
}
@@ -1487,6 +1586,18 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}//ViewHolder
//**********************************************************************************************
+ //Use object of this class for synchronization
+ public static class Lock {
+ private boolean condition;
+
+ public boolean conditionMet() {
+ return condition;
+ }
+
+ public void setCondition(boolean condition) {
+ this.condition = condition;
+ }
+ }
//**********************************************************************************************
}//MainActivity