summaryrefslogtreecommitdiff
path: root/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/Test9.java
blob: f0a885d47fa323369c5e09f10a7a0b3403ce4081 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
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";

        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();

        return benchmarkName + ":" + getBenchmarkResult(5, integrationType);
    }


    public boolean stopBenchmark(){
        isJavaCanceled = true;
        Log.i(TAG, "stopBenchmark: isJNICanceled");
        return true;
    }
}