Mercurial > hg > Members > tatsuki > bench > jungle-core
comparison src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TreeMapBenchMark.java @ 183:066d9c5758dc
change TreeContext
author | tatsuki |
---|---|
date | Mon, 23 Mar 2015 15:44:28 +0900 |
parents | 2e6ca84686da |
children | 6d125ba315d8 |
comparison
equal
deleted
inserted
replaced
182:67d4c68578cf | 183:066d9c5758dc |
---|---|
1 package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.test; | 1 package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.test; |
2 | 2 |
3 import fj.Ord; | 3 import fj.Ord; |
4 import fj.data.List; | |
5 import fj.data.Option; | |
4 import fj.data.TreeMap; | 6 import fj.data.TreeMap; |
5 import org.xml.sax.SAXException; | 7 import org.xml.sax.SAXException; |
6 | 8 |
7 import javax.xml.parsers.ParserConfigurationException; | 9 import javax.xml.parsers.ParserConfigurationException; |
8 import java.io.*; | 10 import java.io.*; |
13 public class TreeMapBenchMark { | 15 public class TreeMapBenchMark { |
14 public static void main(String[] args) throws InterruptedException, IOException, ParserConfigurationException, SAXException { | 16 public static void main(String[] args) throws InterruptedException, IOException, ParserConfigurationException, SAXException { |
15 | 17 |
16 | 18 |
17 if (args.length == 0) { | 19 if (args.length == 0) { |
18 System.out.println("args fj or util"); | 20 System.out.println("args get or getLoop or list"); |
19 System.exit(0); | 21 System.exit(0); |
20 } | 22 } |
21 | 23 |
22 Runtime rt = Runtime.getRuntime(); | 24 Runtime rt = Runtime.getRuntime(); |
23 int cpuNum = rt.availableProcessors(); | 25 int cpuNum = rt.availableProcessors(); |
24 | 26 |
25 File file = new File("./time//get" + args[0] + "TreeMapTime"); | 27 File file = new File("./time/" + args[0] + "Time"); |
26 | 28 |
27 PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); | 29 PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); |
28 | 30 |
29 AbstractTreeMapThread readThread[] = null; | 31 AbstractTreeMapThread readThread[] = null; |
30 | 32 |
31 for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) { | 33 TreeMap<String, String> map = TreeMap.empty(Ord.stringOrd); |
34 List<String> list = List.nil(); | |
35 if (args[0].equals("list")) { | |
36 for (int count = 0 ;count < 100 ; count++) { | |
37 list = list.cons(String.valueOf(count)); | |
38 } | |
39 } | |
40 for (int count = 0 ;count < 1000 ; count++) { | |
41 map = map.set(String.valueOf(count), String.valueOf(count)); | |
42 } | |
43 for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) { | |
44 | |
32 readThread = new AbstractTreeMapThread[THREAD_COUNT]; | 45 readThread = new AbstractTreeMapThread[THREAD_COUNT]; |
33 | 46 |
34 if (args[0].equals("fj")) { | 47 if (args[0].equals("getLoop")) { |
35 TreeMap<String, String> map = TreeMap.empty(Ord.stringOrd); | |
36 map = map.set("test","'test"); | |
37 for (int count = 0; THREAD_COUNT > count; count++) { | 48 for (int count = 0; THREAD_COUNT > count; count++) { |
38 readThread[count] = new FunctionalTreeMapReadThread(map); | 49 readThread[count] = new FJTreeMapGetLoopThread(map); |
39 } | 50 } |
40 } else if (args[0].equals("util")) { | 51 } else if (args[0].equals("get")) { |
41 java.util.TreeMap map = new java.util.TreeMap(); | |
42 map.put("test","test"); | |
43 for (int count = 0; THREAD_COUNT > count; count++) { | 52 for (int count = 0; THREAD_COUNT > count; count++) { |
44 readThread[count] = new UtilTreeMapReadThread(map); | 53 readThread[count] = new FJTreeMapGetIteratorThread(map); |
45 } | 54 } |
46 } else { | 55 } else if (args[0].equals("list")) { |
56 for (int count = 0; THREAD_COUNT > count; count++) { | |
57 readThread[count] = new FJListAccessThread(Option.<List<String>>some(list)); | |
58 } | |
59 } else{ | |
47 System.out.println("not allow args"); | 60 System.out.println("not allow args"); |
48 System.exit(0); | 61 System.exit(0); |
49 } | 62 } |
50 | 63 |
51 for (int count = 0; THREAD_COUNT > count; count++) { | 64 for (int count = 0; THREAD_COUNT > count; count++) { |