blob: 51f05311f2dce7b30b04124ba83e204b247877aa [file] [log] [blame]
package org.linaro.iasenov.benchmarkframework;
import android.util.Log;
import java.io.PrintStream;
import art_benchmarks.algorithm.AccessFannkuch;
import art_benchmarks.algorithm.BitopsNSieve;
import art_benchmarks.algorithm.CryptoMD5;
import art_benchmarks.algorithm.CryptoSHA1;
import art_benchmarks.algorithm.DeltaBlue;
import art_benchmarks.algorithm.Dhrystone;
import art_benchmarks.algorithm.Linpack;
import art_benchmarks.algorithm.NSieve;
import art_benchmarks.algorithm.Richards;
import art_benchmarks.algorithm.Sort;
/**
* Created by iasenov on 9/20/16.
*/
public class Test9 extends BaseBenchmark{
private String TAG = "Algorithm(ART)";
static boolean isJavaCanceled = false;
public String startBenchmark(int count) {
isJavaCanceled = false;
version = " Algorithm ";
benchmarkName = "Test9";
integrationType = "SL";
chartName = "Algorithm(ART)";
long before;
long after;
clear();
//****Redirect System.out and Syste.err****
PrintStream stdOut = System.out;
PrintStream stdErrt = System.err;
PrintStream interceptor_stdout = new Interceptor(stdOut);
PrintStream interceptor_err = new Interceptor(stdErrt);
System.setOut(interceptor_stdout);// just add the interceptor
System.setErr(interceptor_err);// just add the interceptor
//****Redirect System.out and Syste.err****
startTest = System.currentTimeMillis();
if(isJavaCanceled) return "";
//***********AccessFannkuch*************
AccessFannkuch obj1 = new AccessFannkuch();
before = System.currentTimeMillis();
obj1.timeAccessFannkuch(109);
after = System.currentTimeMillis();
obj1.verify();
System.out.println("art_benchmarks/algorithm/AccessFankuch: " + (after - before));
//***********AccessFannkuch*************
if(isJavaCanceled) return "";
//***********BitopsNSieve*************
BitopsNSieve obj2 = new BitopsNSieve();
before = System.currentTimeMillis();
obj2.timeBitopsNSieve(189);
after = System.currentTimeMillis();
obj2.verify();
System.out.println("art_benchmarks/algorithm/BitopsNSieve: " + (after - before));
//***********BitopsNSieve*************
if(isJavaCanceled) return "";
//***********CryptoMD5*************
CryptoMD5 obj3 = new CryptoMD5();
before = System.currentTimeMillis();
obj3.timeHexMD5(2305);
after = System.currentTimeMillis();
obj3.verify();
System.out.println("art_benchmarks/algorithm/CryptoMD5: " + (after - before));
//***********CryptoMD5*************
if(isJavaCanceled) return "";
//***********CryptoSHA1*************
CryptoSHA1 obj4 = new CryptoSHA1();
before = System.currentTimeMillis();
obj4.timeHexSHA1(1600);
after = System.currentTimeMillis();
obj4.verify();
System.out.println("art_benchmarks/algorithm/CryptoSHA1: " + (after - before));
//***********CryptoSHA1*************
if(isJavaCanceled) return "";
// /***********DeltaBlue*************
int rc = 0;
DeltaBlue obj5 = new DeltaBlue();
before = System.currentTimeMillis();
obj5.timeDeltaBlue(300);
after = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/DeltaBlue: " + (after - before));
if (!obj5.verifyDeltaBlue()) {
rc++;
}
//System.exit(rc);
//***********DeltaBlue*************
if(isJavaCanceled) return "";
//***********Dhrystone*************
rc = 0;
Dhrystone obj6 = new Dhrystone();
before = System.currentTimeMillis();
obj6.timeDhrystone(1);
after = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Dhrystone: " + (after - before));
if (!obj6.verifyDhrystone()) {
rc++;
}
//System.exit(rc);
//***********Dhrystone*************
if(isJavaCanceled) return "";
//***********Linpack*************
rc = 0;
Linpack obj7 = new Linpack();
before = System.currentTimeMillis();
obj7.timeLinpack(200);
after = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Linpack: " + (after - before));
if (!obj7.verifyLinpack()) {
rc++;
}
//System.exit(rc);
//***********Linpack*************
if(isJavaCanceled) return "";
//***********NSieve*************
NSieve obj8 = new NSieve();
before = System.currentTimeMillis();
obj8.timeNSieveAccess(100);
after = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/NSieve.NSieveAccess: " + (after - before));
//***********NSieve*************
if(isJavaCanceled) return "";
//***********Richards*************
Richards obj9 = new Richards();
before = System.currentTimeMillis();
obj9.timeRichards(1200);
after = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Richards: " + (after - before));
//***********Richards*************
if(isJavaCanceled) return "";
//***********Sort*************
rc = 0;
long b; // before
long a; // after
Sort o = new Sort(); // object
// The number of iterations run were calibrated so that each benchmark runs in about one second.
// CHECKSTYLE.OFF: LineLength
// CHECKSTYLE.OFF: OneStatementPerLine
b = System.currentTimeMillis(); o.timeBubbleSort____16(700000); a = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Sort.BubbleSort____16: " + (a - b));
if(isJavaCanceled) return "";
b = System.currentTimeMillis(); o.timeBubbleSort___128(15500); a = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Sort.BubbleSort___128: " + (a - b));
if(isJavaCanceled) return "";
b = System.currentTimeMillis(); o.timeBubbleSort__2048(60); a = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Sort.BubbleSort__2048: " + (a - b));
if (!o.verifyBubbleSort()) {
rc++;
}
b = System.currentTimeMillis(); o.timeInsertionSort____16(1450000); a = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Sort.InsertionSort____16: " + (a - b));
if(isJavaCanceled) return "";
b = System.currentTimeMillis(); o.timeInsertionSort___128(40000); a = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Sort.InsertionSort___128: " + (a - b));
if(isJavaCanceled) return "";
b = System.currentTimeMillis(); o.timeInsertionSort__2048(170); a = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Sort.InsertionSort__2048: " + (a - b));
if (!o.verifyInsertionSort()) {
rc++;
}
if(isJavaCanceled) return "";
b = System.currentTimeMillis(); o.timeMergeSort____16(110000); a = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Sort.MergeSort____16: " + (a - b));
if(isJavaCanceled) return "";
b = System.currentTimeMillis(); o.timeMergeSort___128(12000); a = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Sort.MergeSort___128: " + (a - b));
if(isJavaCanceled) return "";
b = System.currentTimeMillis(); o.timeMergeSort__2048(600); a = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Sort.MergeSort__2048: " + (a - b));
if (!o.verifyMergeSort()) {
rc++;
}
if(isJavaCanceled) return "";
b = System.currentTimeMillis(); o.timeSystemSort____16(1200000); a = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Sort.SystemSort____16: " + (a - b));
if(isJavaCanceled) return "";
b = System.currentTimeMillis(); o.timeSystemSort___128(100000); a = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Sort.SystemSort___128: " + (a - b));
if(isJavaCanceled) return "";
b = System.currentTimeMillis(); o.timeSystemSort__2048(6250); a = System.currentTimeMillis();
System.out.println("art_benchmarks/algorithm/Sort.SystemSort__2048: " + (a - b));
if (!o.verifySystemSort()) {
rc++;
}
// CHECKSTYLE.ON: OneStatementPerLine
// CHECKSTYLE.ON: LineLength
//System.exit(rc);
//***********Sort*************
xout[2] = Interceptor.outputTxt;
Interceptor.clear();
endTest = System.currentTimeMillis();
sendElapsedTimeToChart();
submitElapsedTime(endTest-startTest);
return benchmarkName + ":" + getBenchmarkResult(5, integrationType);
}
public boolean stopBenchmark(){
isJavaCanceled = true;
Log.i(TAG, "stopBenchmark: isJNICanceled");
return true;
}
}