Mercurial > hg > Members > tatsuki > jungle-bench
comparison src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java @ 20:195c1a644550
benchmark add
author | tatsuki |
---|---|
date | Tue, 17 Mar 2015 15:37:19 +0900 |
parents | 17cc11b04157 |
children | c8d8864714d4 |
comparison
equal
deleted
inserted
replaced
19:17cc11b04157 | 20:195c1a644550 |
---|---|
11 import javax.xml.parsers.ParserConfigurationException; | 11 import javax.xml.parsers.ParserConfigurationException; |
12 | 12 |
13 import org.xml.sax.SAXException; | 13 import org.xml.sax.SAXException; |
14 | 14 |
15 import jp.ac.u_ryukyu.cr.ie.tatsuki.xmlTestBbs.JuGrix; | 15 import jp.ac.u_ryukyu.cr.ie.tatsuki.xmlTestBbs.JuGrix; |
16 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; | |
17 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; | |
18 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; | |
19 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; | 16 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; |
20 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; | 17 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; |
21 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; | |
22 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; | |
23 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; | |
24 | 18 |
25 public class TransactionPerSecondMeasurement { | 19 public class TransactionPerSecondMeasurement { |
26 | 20 |
27 public static void main(String[] args) throws InterruptedException, IOException, ParserConfigurationException, SAXException { | 21 public static void main(String[] args) throws InterruptedException, IOException, ParserConfigurationException, SAXException { |
28 // Jungle jungle = new DefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser())); | 22 System.out.println("endCreatejugrix"); |
29 // JungleTree tree = jungle.createNewTree("testTree"); | 23 JuGrix jugrix = extendXmlTree.createJuGrix(true,400); |
30 // JungleTreeEditor editor = tree.getTreeEditor(); | |
31 // editor = createTree(0, new DefaultNodePath(), editor); | |
32 JuGrix jugrix = extendXmlTree.createJuGrix(true,100); | |
33 System.out.println("endCreatejugrixa "); | |
34 // editor = editor.success().b(); | |
35 System.out.println(Runtime.getRuntime().availableProcessors()); | 24 System.out.println(Runtime.getRuntime().availableProcessors()); |
36 | 25 |
37 if (args.length > 0) { | 26 if (args.length > 0) { |
38 | 27 |
39 if (args[0].equals("read")) | 28 if (args[0].equals("read")) |
45 System.out.println("Please with the argument"); | 34 System.out.println("Please with the argument"); |
46 } | 35 } |
47 | 36 |
48 private static void readAndWrite(JuGrix jugrix) throws InterruptedException, IOException { | 37 private static void readAndWrite(JuGrix jugrix) throws InterruptedException, IOException { |
49 System.out.println("read and write"); | 38 System.out.println("read and write"); |
50 File file = new File("./time/readAndWrite"); | 39 Runtime rt = Runtime.getRuntime(); |
40 int cpuNum = rt.availableProcessors(); | |
41 | |
42 File file = new File("./time/newTransactionReadAndWrite"); | |
51 PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); | 43 PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); |
52 for (int THREAD_COUNT = 1; THREAD_COUNT <= 12; THREAD_COUNT++) { | 44 |
45 for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) { | |
53 ReadJungleThread readThread[] = new ReadJungleThread[THREAD_COUNT]; | 46 ReadJungleThread readThread[] = new ReadJungleThread[THREAD_COUNT]; |
54 for (int count = 0; THREAD_COUNT > count; count++) { | 47 for (int count = 0; THREAD_COUNT > count; count++) { |
55 readThread[count] = new ReadJungleThread(jugrix); | 48 readThread[count] = new ReadJungleThread(jugrix); |
56 } | 49 } |
57 | 50 |
58 WriteJungleThread writeThread = new WriteJungleThread(null); | 51 WriteJungleThread writeThread = new WriteJungleThread(jugrix); |
59 writeThread.start(); | 52 writeThread.start(); |
60 for (int count = 0; THREAD_COUNT > count; count++) { | 53 for (int count = 0; THREAD_COUNT > count; count++) { |
61 readThread[count].start(); | 54 readThread[count].start(); |
62 } | 55 } |
63 | 56 |
68 int readCount = 0; | 61 int readCount = 0; |
69 | 62 |
70 for (int count = 0; THREAD_COUNT > count; count++) { | 63 for (int count = 0; THREAD_COUNT > count; count++) { |
71 readCount = readCount + readThread[count].getFindCount(); | 64 readCount = readCount + readThread[count].getFindCount(); |
72 readThread[count].set(false); | 65 readThread[count].set(false); |
73 System.out.println(readThread[count].getFindCount()); | |
74 } | 66 } |
75 | 67 |
76 | 68 |
77 pw.println(THREAD_COUNT + " " + readCount); | 69 pw.println(THREAD_COUNT + " " + readCount); |
78 System.out.println(THREAD_COUNT + "readCount = " + readCount); | 70 System.out.println(THREAD_COUNT + "readCount = " + readCount); |
80 } | 72 } |
81 pw.close(); | 73 pw.close(); |
82 } | 74 } |
83 | 75 |
84 private static void readOnly(JuGrix jugrix) throws InterruptedException, IOException { | 76 private static void readOnly(JuGrix jugrix) throws InterruptedException, IOException { |
85 System.out.println("read onlya"); | 77 System.out.println("read only"); |
78 Runtime rt = Runtime.getRuntime(); | |
79 int cpuNum = rt.availableProcessors(); | |
80 | |
86 File file = new File("./time/readOnly"); | 81 File file = new File("./time/readOnly"); |
87 PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); | 82 PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); |
88 for (int THREAD_COUNT = 1; THREAD_COUNT <= 12; THREAD_COUNT++) { | 83 for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) { |
89 ReadJungleThread readThread[] = new ReadJungleThread[THREAD_COUNT]; | 84 ReadJungleThread readThread[] = new ReadJungleThread[THREAD_COUNT]; |
90 ; | 85 ; |
91 for (int count = 0; THREAD_COUNT > count; count++) { | 86 for (int count = 0; THREAD_COUNT > count; count++) { |
92 readThread[count] = new ReadJungleThread(jugrix); | 87 readThread[count] = new ReadJungleThread(jugrix); |
93 } | 88 } |
102 int readCount = 0; | 97 int readCount = 0; |
103 | 98 |
104 for (int count = 0; THREAD_COUNT > count; count++) { | 99 for (int count = 0; THREAD_COUNT > count; count++) { |
105 readCount = readCount + readThread[count].getFindCount(); | 100 readCount = readCount + readThread[count].getFindCount(); |
106 readThread[count].set(false); | 101 readThread[count].set(false); |
107 System.out.println(readThread[count].getFindCount()); | |
108 } | 102 } |
103 | |
109 pw.println(THREAD_COUNT + " " + readCount); | 104 pw.println(THREAD_COUNT + " " + readCount); |
110 System.out.println(THREAD_COUNT + "readCount = " + readCount); | 105 System.out.println(THREAD_COUNT + "readCount = " + readCount); |
111 } | 106 } |
107 | |
112 pw.close(); | 108 pw.close(); |
113 } | 109 } |
114 | 110 |
115 static String key = "KEY"; | 111 static String key = "KEY"; |
116 | 112 |