summaryrefslogtreecommitdiff
path: root/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/Test11.java
blob: 0c4a0157c7b0dd3d6868b2c30ef8505a573eeeb8 (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
package org.linaro.iasenov.benchmarkframework;

import android.util.Log;

import java.io.PrintStream;

import art_benchmarks.caffeinemark.FloatAtom;
import art_benchmarks.caffeinemark.LogicAtom;
import art_benchmarks.caffeinemark.LoopAtom;
import art_benchmarks.caffeinemark.MethodAtom;
import art_benchmarks.caffeinemark.SieveAtom;
import art_benchmarks.caffeinemark.StringAtom;

/**
 * Created by iasenov on 9/21/16.
 */
public class Test11 extends BaseBenchmark{

    private String TAG = "Caffeine(ART)";
    static boolean  isJavaCanceled = false;

    public String startBenchmark(int count) {

        isJavaCanceled = false;

        version = " Caffeine(ART) ";
        benchmarkName = "Test11";
        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 "";
        //***********FloatAtom*************
        int rc = 0;
        FloatAtom obj = new FloatAtom();

        before = System.currentTimeMillis();
        obj.timeFloatAtom(100);
        after = System.currentTimeMillis();

        if (!obj.verifyFloatAtom()) {
            rc++;
        }
        System.out.println("art_benchmarks/caffeinemark/FloatAtom: " + (after - before));
        //System.exit(rc);
        //***********FloatAtom*************



        if(isJavaCanceled) return "";
        //***********LogicAtom*************
        rc = 0;
        LogicAtom obj1 = new LogicAtom();

        before = System.currentTimeMillis();
        obj1.timeLogicAtom(80);
        after = System.currentTimeMillis();

        if (!obj1.verifyLogicAtom()) {
            rc++;
        }
        System.out.println("art_benchmarks/caffeinemark/LogicAtom: " + (after - before));
        //System.exit(rc);
        //***********LogicAtom*************



        if(isJavaCanceled) return "";
        //***********LoopAtom*************
        rc = 0;
        LoopAtom obj2 = new LoopAtom();

        before = System.currentTimeMillis();
        obj2.timeLoopAtom(120);
        after = System.currentTimeMillis();

        if (!obj2.verifyLoopAtom()) {
            rc++;
        }
        System.out.println("art_benchmarks/caffeinemark/LoopAtom: " + (after - before));
        //System.exit(rc);
        //***********LoopAtom*************

        if(isJavaCanceled) return "";
        //***********MethodAtom*************
        rc = 0;
        MethodAtom obj3 = new MethodAtom();

        before = System.currentTimeMillis();
        obj3.timeMethodAtom(9);
        after = System.currentTimeMillis();

        if (!obj3.verifyMethodAtom()) {
            rc++;
        }
        System.out.println("art_benchmarks/caffeinemark/MethodAtom: " + (after - before));
        //System.exit(rc);
        //***********MethodAtom*************



        if(isJavaCanceled) return "";
        //***********SieveAtom*************
        rc = 0;
        SieveAtom obj4 = new SieveAtom();

        before = System.currentTimeMillis();
        obj4.timeSieveAtom(90);
        after = System.currentTimeMillis();

        if (!obj4.verifySieveAtom()) {
            rc++;
        }
        System.out.println("art_benchmarks/caffeinemark/SieveAtom: " + (after - before));
        //System.exit(rc);
        //***********SieveAtom*************


        if(isJavaCanceled) return "";
        //***********StringAtom*************
        rc = 0;
        StringAtom obj5 = new StringAtom();

        before = System.currentTimeMillis();
        obj5.timeStringAtom(50);
        after = System.currentTimeMillis();

        if (!obj5.verifyStringAtom()) {
            rc++;
        }
        System.out.println("art_benchmarks/caffeinemark/StringAtom: " + (after - before));
        //System.exit(rc);
        //***********StringAtom*************


        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;
    }
}