179
|
1 package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.test;
|
|
2
|
180
|
3 import fj.Ord;
|
|
4 import fj.data.TreeMap;
|
179
|
5 import org.xml.sax.SAXException;
|
|
6
|
|
7 import javax.xml.parsers.ParserConfigurationException;
|
|
8 import java.io.*;
|
|
9
|
|
10 /**
|
|
11 * Created by e115731 on 15/03/17.
|
|
12 */
|
|
13 public class TreeMapBenchMark {
|
|
14 public static void main(String[] args) throws InterruptedException, IOException, ParserConfigurationException, SAXException {
|
180
|
15
|
179
|
16
|
180
|
17 if (args.length == 0) {
|
|
18 System.out.println("args fj or util");
|
|
19 System.exit(0);
|
|
20 }
|
|
21
|
179
|
22 Runtime rt = Runtime.getRuntime();
|
|
23 int cpuNum = rt.availableProcessors();
|
|
24
|
181
|
25 File file = new File("./time/get" + args[0] + "TreeMapTime");
|
180
|
26
|
179
|
27 PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
|
180
|
28
|
|
29 AbstractTreeMapThread readThread[] = null;
|
|
30
|
|
31 for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) {
|
|
32 readThread = new AbstractTreeMapThread[THREAD_COUNT];
|
|
33
|
|
34 if (args[0].equals("fj")) {
|
|
35 TreeMap<String, String> map = TreeMap.empty(Ord.stringOrd);
|
|
36 map = map.set("test","'test");
|
|
37 for (int count = 0; THREAD_COUNT > count; count++) {
|
|
38 readThread[count] = new FunctionalTreeMapReadThread(map);
|
|
39 }
|
|
40 } else if (args[0].equals("util")) {
|
|
41 java.util.TreeMap map = new java.util.TreeMap();
|
|
42 map.put("test","test");
|
|
43 for (int count = 0; THREAD_COUNT > count; count++) {
|
|
44 readThread[count] = new UtilTreeMapReadThread(map);
|
|
45 }
|
|
46 } else {
|
|
47 System.out.println("not allow args");
|
|
48 System.exit(0);
|
|
49 }
|
179
|
50
|
|
51 for (int count = 0; THREAD_COUNT > count; count++) {
|
|
52 readThread[count].start();
|
|
53 }
|
|
54
|
|
55 System.out.println("StartThread");
|
|
56
|
|
57 Thread.sleep(1000);
|
|
58 long readCount = 0;
|
|
59
|
|
60 for (int count = 0; THREAD_COUNT > count; count++) {
|
|
61 readCount = readCount + readThread[count].getFindCount();
|
|
62 readThread[count].set(false);
|
|
63 }
|
|
64
|
|
65 pw.println(THREAD_COUNT + " " + readCount);
|
|
66 System.out.println(THREAD_COUNT + "readCount = " + readCount);
|
|
67 }
|
|
68
|
|
69 pw.close();
|
|
70 }
|
|
71
|
|
72 }
|