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

import android.util.Log;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;


import fhourstones.Game;
import fhourstones.SearchGame;
import fhourstones.TransGame;

/**
 * Created by iasenov on 10/24/16.
 */
public class Test35 extends BaseBenchmark{

    private String TAG = "Fhourstones";
    static boolean  isJavaCanceled = false;

    public String startBenchmark(int count) {

        isJavaCanceled = false;

        version = " Fhourstones ";
        benchmarkName = "Test35";
        integrationType = "SL";
        chartName = "Fhourstones";

        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 "";
        //***********SearchGame*************

        before = System.currentTimeMillis();


        System.out.println("Fhourstones 3.1 (Java)");
        System.out.println("Boardsize = " + Game.WIDTH + "x" + Game.HEIGHT);
        System.out.println("Using " + TransGame.TRANSIZE + " transposition table entries.");
        SearchGame c4 = new SearchGame();


        String inputs = "45461667\n" +
                        "35333571\n" +
                        "13333111";

        InputStream istream = new ByteArrayInputStream(inputs.getBytes());


        BufferedReader dis = new BufferedReader(new InputStreamReader(istream/*System.in*/));
        DecimalFormat df = new DecimalFormat("######.###");

        for (;;) {
            String line=null;
            try {
                line = dis.readLine();
            } catch (IOException e) {
                System.out.println(e);
                //System.exit(0);
            }
            if (line == null)
                break;
            c4.reset();
            for (int i=0; i < line.length(); i++)
                c4.makemove(line.charAt(i) - '1');
            System.out.println("\nSolving " + c4.nplies + "-ply position after "
                    + c4.toString() + " . . .");

            c4.emptyTT();
            int result = c4.solve();
            long poscnt = c4.posed;
            int work;
            for (work=0; (poscnt>>=1) != 0; work++) ; //work = log #transpositions
            System.out.println("score = " + result + " (" +
                    "#-<=>+".charAt(result) + ")  work = " + work);
            System.out.println("" + c4.nodes + " pos / " + c4.msecs +
                    " msec = " + df.format((double)c4.nodes/c4.msecs) + " Kpos/sec");
            System.out.println(c4.htstat());
        }


        after = System.currentTimeMillis();

        System.out.println("fhourstones/SearchGame: " + (after - before));
        //***********AccessNBody*************





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