Mercurial > hg > Members > tatsuki > jungle-bench
diff 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 |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java Sat Dec 06 12:00:21 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java Mon Dec 08 01:08:03 2014 +0900 @@ -14,58 +14,65 @@ public class TransactionPerSecondMeasurement { - static int THREAD_COUNT = 2; + public static void main(String[] args) throws InterruptedException { - public static void main(String[] args) throws InterruptedException { + Jungle jungle = new DefaultJungle(null, "hoge", new DefaultTreeEditor( + new DefaultTraverser())); + JungleTree tree = jungle.createNewTree("testTree"); + JungleTreeEditor editor = tree.getTreeEditor(); + editor = createTree(0, new DefaultNodePath(), editor); + editor = editor.success().b(); - FunctionThread thread[]; - thread = new FunctionThread[THREAD_COUNT]; + for (int THREAD_COUNT = 1; THREAD_COUNT < 12; THREAD_COUNT++) { + FunctionThread thread[]; + thread = new FunctionThread[THREAD_COUNT]; + for (int count = 0; THREAD_COUNT > count; count++) { + thread[count] = new FunctionThread(tree); + } - Jungle jungle = new DefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser())); - JungleTree tree = jungle.createNewTree("testTree"); - JungleTreeEditor editor = tree.getTreeEditor(); - editor = createTree(0, new DefaultNodePath(), editor); - editor = editor.success().b(); - + System.out.println("StartThread"); + for (int count = 0; THREAD_COUNT > count; count++) { + thread[count].start(); + } - for (int count = 0; THREAD_COUNT > count; count++) { - thread[count] = new FunctionThread(tree); - } + for (int count = 0; count < 4; count++) { + Thread.sleep(2500); + // editor = editor.putAttribute(new DefaultNodePath(), key, + // ByteBuffer.wrap("2".getBytes())).b(); + // editor = editor.success().b(); + } + int readCount = 0; + for (int count = 0; THREAD_COUNT > count; count++) { + readCount = readCount + thread[count].getFindCount(); + thread[count].set(false); + System.out.println(thread[count].getFindCount()); + } - System.out.println("StartThread"); - for (int count = 0; THREAD_COUNT > count; count++) { - thread[count].start(); + System.out.println(THREAD_COUNT + "readCount = " + readCount); + } + System.out.println("end"); } - Thread.sleep(1000); - // editor = editor.putAttribute(new DefaultNodePath().add(0), key, ByteBuffer.wrap("2".getBytes())).b(); - // editor = editor.success().b(); - Thread.sleep(1000); - // editor = editor.putAttribute(new DefaultNodePath().add(0), key, ByteBuffer.wrap("2".getBytes())).b().success().b(); - Thread.sleep(1000); - for (int count = 0; THREAD_COUNT > count; count++) { - System.out.println(thread[count].getFindCount()); - } + static String key = "KEY"; - } - - static String key = "KEY"; - - public static JungleTreeEditor createTree(int deep, NodePath path, JungleTreeEditor editor) { + public static JungleTreeEditor createTree(int deep, NodePath path, + JungleTreeEditor editor) { - Random rnd = new Random(); - String value1 = String.valueOf(rnd.nextInt(1000)); - String value2 = String.valueOf(rnd.nextInt(1000)); - editor = editor.addNewChildAt(path, 0).b(); - editor = editor.putAttribute(path.add(0), key, ByteBuffer.wrap(value1.getBytes())).b(); - editor = editor.addNewChildAt(path, 1).b(); - editor = editor.putAttribute(path.add(0), key, ByteBuffer.wrap(value2.toString().getBytes())).b(); - deep++; + Random rnd = new Random(); + String value1 = String.valueOf(rnd.nextInt(1000)); + String value2 = String.valueOf(rnd.nextInt(1000)); + editor = editor.addNewChildAt(path, 0).b(); + editor = editor.putAttribute(path.add(0), key, + ByteBuffer.wrap(value1.getBytes())).b(); + editor = editor.addNewChildAt(path, 1).b(); + editor = editor.putAttribute(path.add(0), key, + ByteBuffer.wrap(value2.toString().getBytes())).b(); + deep++; - if (deep < 2) { - editor = createTree(deep, path.add(0), editor); - editor = createTree(deep, path.add(1), editor); + if (deep < 10) { + editor = createTree(deep, path.add(0), editor); + editor = createTree(deep, path.add(1), editor); + } + return editor; } - return editor; - } }