Mercurial > hg > Members > tatsuki > jungle-bench
comparison src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java @ 15:89478f2ea07f
change src name TimeMeasurementJuGrix to TimeMeasurementJuGrixFunction
author | one |
---|---|
date | Mon, 08 Dec 2014 01:08:03 +0900 |
parents | 7c544969d4c9 |
children | 917ecf2c7350 |
comparison
equal
deleted
inserted
replaced
14:047bbe894005 | 15:89478f2ea07f |
---|---|
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; | 12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; |
13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; | 13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; |
14 | 14 |
15 public class TransactionPerSecondMeasurement { | 15 public class TransactionPerSecondMeasurement { |
16 | 16 |
17 static int THREAD_COUNT = 2; | 17 public static void main(String[] args) throws InterruptedException { |
18 | 18 |
19 public static void main(String[] args) throws InterruptedException { | 19 Jungle jungle = new DefaultJungle(null, "hoge", new DefaultTreeEditor( |
20 new DefaultTraverser())); | |
21 JungleTree tree = jungle.createNewTree("testTree"); | |
22 JungleTreeEditor editor = tree.getTreeEditor(); | |
23 editor = createTree(0, new DefaultNodePath(), editor); | |
24 editor = editor.success().b(); | |
20 | 25 |
21 FunctionThread thread[]; | 26 for (int THREAD_COUNT = 1; THREAD_COUNT < 12; THREAD_COUNT++) { |
22 thread = new FunctionThread[THREAD_COUNT]; | 27 FunctionThread thread[]; |
28 thread = new FunctionThread[THREAD_COUNT]; | |
29 for (int count = 0; THREAD_COUNT > count; count++) { | |
30 thread[count] = new FunctionThread(tree); | |
31 } | |
23 | 32 |
24 Jungle jungle = new DefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser())); | 33 System.out.println("StartThread"); |
25 JungleTree tree = jungle.createNewTree("testTree"); | 34 for (int count = 0; THREAD_COUNT > count; count++) { |
26 JungleTreeEditor editor = tree.getTreeEditor(); | 35 thread[count].start(); |
27 editor = createTree(0, new DefaultNodePath(), editor); | 36 } |
28 editor = editor.success().b(); | |
29 | 37 |
38 for (int count = 0; count < 4; count++) { | |
39 Thread.sleep(2500); | |
40 // editor = editor.putAttribute(new DefaultNodePath(), key, | |
41 // ByteBuffer.wrap("2".getBytes())).b(); | |
42 // editor = editor.success().b(); | |
43 } | |
44 int readCount = 0; | |
45 for (int count = 0; THREAD_COUNT > count; count++) { | |
46 readCount = readCount + thread[count].getFindCount(); | |
47 thread[count].set(false); | |
48 System.out.println(thread[count].getFindCount()); | |
49 } | |
30 | 50 |
31 for (int count = 0; THREAD_COUNT > count; count++) { | 51 System.out.println(THREAD_COUNT + "readCount = " + readCount); |
32 thread[count] = new FunctionThread(tree); | 52 } |
53 System.out.println("end"); | |
33 } | 54 } |
34 | 55 |
35 System.out.println("StartThread"); | 56 static String key = "KEY"; |
36 for (int count = 0; THREAD_COUNT > count; count++) { | 57 |
37 thread[count].start(); | 58 public static JungleTreeEditor createTree(int deep, NodePath path, |
59 JungleTreeEditor editor) { | |
60 | |
61 Random rnd = new Random(); | |
62 String value1 = String.valueOf(rnd.nextInt(1000)); | |
63 String value2 = String.valueOf(rnd.nextInt(1000)); | |
64 editor = editor.addNewChildAt(path, 0).b(); | |
65 editor = editor.putAttribute(path.add(0), key, | |
66 ByteBuffer.wrap(value1.getBytes())).b(); | |
67 editor = editor.addNewChildAt(path, 1).b(); | |
68 editor = editor.putAttribute(path.add(0), key, | |
69 ByteBuffer.wrap(value2.toString().getBytes())).b(); | |
70 deep++; | |
71 | |
72 if (deep < 10) { | |
73 editor = createTree(deep, path.add(0), editor); | |
74 editor = createTree(deep, path.add(1), editor); | |
75 } | |
76 return editor; | |
38 } | 77 } |
39 | |
40 Thread.sleep(1000); | |
41 // editor = editor.putAttribute(new DefaultNodePath().add(0), key, ByteBuffer.wrap("2".getBytes())).b(); | |
42 // editor = editor.success().b(); | |
43 Thread.sleep(1000); | |
44 // editor = editor.putAttribute(new DefaultNodePath().add(0), key, ByteBuffer.wrap("2".getBytes())).b().success().b(); | |
45 Thread.sleep(1000); | |
46 for (int count = 0; THREAD_COUNT > count; count++) { | |
47 System.out.println(thread[count].getFindCount()); | |
48 } | |
49 | |
50 } | |
51 | |
52 static String key = "KEY"; | |
53 | |
54 public static JungleTreeEditor createTree(int deep, NodePath path, JungleTreeEditor editor) { | |
55 | |
56 Random rnd = new Random(); | |
57 String value1 = String.valueOf(rnd.nextInt(1000)); | |
58 String value2 = String.valueOf(rnd.nextInt(1000)); | |
59 editor = editor.addNewChildAt(path, 0).b(); | |
60 editor = editor.putAttribute(path.add(0), key, ByteBuffer.wrap(value1.getBytes())).b(); | |
61 editor = editor.addNewChildAt(path, 1).b(); | |
62 editor = editor.putAttribute(path.add(0), key, ByteBuffer.wrap(value2.toString().getBytes())).b(); | |
63 deep++; | |
64 | |
65 if (deep < 2) { | |
66 editor = createTree(deep, path.add(0), editor); | |
67 editor = createTree(deep, path.add(1), editor); | |
68 } | |
69 return editor; | |
70 } | |
71 } | 78 } |