Mercurial > hg > Members > tatsuki > jungle-bench
diff src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java @ 21:c8d8864714d4
add build.gradle
author | tatsuki |
---|---|
date | Tue, 28 Apr 2015 08:16:08 +0900 |
parents | 195c1a644550 |
children | 69dca2ab1783 |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java Tue Mar 17 15:37:19 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java Tue Apr 28 08:16:08 2015 +0900 @@ -18,113 +18,117 @@ public class TransactionPerSecondMeasurement { - public static void main(String[] args) throws InterruptedException, IOException, ParserConfigurationException, SAXException { - System.out.println("endCreatejugrix"); - JuGrix jugrix = extendXmlTree.createJuGrix(true,400); - System.out.println(Runtime.getRuntime().availableProcessors()); + public static void main(String[] args) throws InterruptedException, IOException, ParserConfigurationException, SAXException { + JuGrix jugrix = extendXmlTree.createJuGrix(true, 400); + System.out.println("endCreatejugrix"); + System.out.println(Runtime.getRuntime().availableProcessors()); + + if (args.length > 0) { - if (args.length > 0) { - - if (args[0].equals("read")) - readOnly(jugrix); - if (args[0].equals("write")) - readAndWrite(jugrix); + if (args[0].equals("read")) + readOnly(jugrix); + if (args[0].equals("write")) + readAndWrite(jugrix); - } else - System.out.println("Please with the argument"); - } + } else + System.out.println("Please with the argument"); + } + + private static void readAndWrite(JuGrix jugrix) throws InterruptedException, IOException { + System.out.println("read and write"); + Runtime rt = Runtime.getRuntime(); + int cpuNum = rt.availableProcessors(); - private static void readAndWrite(JuGrix jugrix) throws InterruptedException, IOException { - System.out.println("read and write"); - Runtime rt = Runtime.getRuntime(); - int cpuNum = rt.availableProcessors(); - - File file = new File("./time/newTransactionReadAndWrite"); - PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); + File file = new File("./time/newTransactionReadAndWrite"); + PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); - for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) { - ReadJungleThread readThread[] = new ReadJungleThread[THREAD_COUNT]; - for (int count = 0; THREAD_COUNT > count; count++) { - readThread[count] = new ReadJungleThread(jugrix); - } + for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) { + ReadJungleThread readThread[] = new ReadJungleThread[THREAD_COUNT]; + for (int count = 0; THREAD_COUNT > count; count++) { + readThread[count] = new ReadJungleThread(jugrix); + } - WriteJungleThread writeThread = new WriteJungleThread(jugrix); - writeThread.start(); - for (int count = 0; THREAD_COUNT > count; count++) { - readThread[count].start(); - } + WriteJungleThread writeThread = new WriteJungleThread(jugrix); + writeThread.start(); + for (int count = 0; THREAD_COUNT > count; count++) { + readThread[count].start(); + } - System.out.println("StartThread"); + System.out.println("StartThread"); - Thread.sleep(1000); - writeThread.set(false); - int readCount = 0; + Thread.sleep(1000); + writeThread.set(false); + int readCount = 0; - for (int count = 0; THREAD_COUNT > count; count++) { - readCount = readCount + readThread[count].getFindCount(); - readThread[count].set(false); - } + for (int count = 0; THREAD_COUNT > count; count++) { + readCount = readCount + readThread[count].getFindCount(); + readThread[count].set(false); + } - pw.println(THREAD_COUNT + " " + readCount); - System.out.println(THREAD_COUNT + "readCount = " + readCount); - Thread.sleep(1000); + pw.println(THREAD_COUNT + " " + readCount); + System.out.println(THREAD_COUNT + "readCount = " + readCount); + Thread.sleep(1000); + } + pw.close(); } - pw.close(); - } - private static void readOnly(JuGrix jugrix) throws InterruptedException, IOException { - System.out.println("read only"); - Runtime rt = Runtime.getRuntime(); - int cpuNum = rt.availableProcessors(); + private static void readOnly(JuGrix jugrix) throws InterruptedException, IOException { + System.out.println("read only"); + Runtime rt = Runtime.getRuntime(); + int cpuNum = rt.availableProcessors(); - File file = new File("./time/readOnly"); - PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); - for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) { - ReadJungleThread readThread[] = new ReadJungleThread[THREAD_COUNT]; - ; - for (int count = 0; THREAD_COUNT > count; count++) { - readThread[count] = new ReadJungleThread(jugrix); - } + File file = new File("./time/readOnly"); + PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); + for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) { + ReadJungleThread readThread[] = new ReadJungleThread[THREAD_COUNT]; + ; + for (int count = 0; THREAD_COUNT > count; count++) { + readThread[count] = new ReadJungleThread(jugrix); + } - for (int count = 0; THREAD_COUNT > count; count++) { - readThread[count].start(); - } + for (int count = 0; THREAD_COUNT > count; count++) { + readThread[count].start(); + } - System.out.println("StartThread"); + System.out.println("StartThread"); - Thread.sleep(1000); - int readCount = 0; + Thread.sleep(1000); + int readCount = 0; - for (int count = 0; THREAD_COUNT > count; count++) { - readCount = readCount + readThread[count].getFindCount(); - readThread[count].set(false); - } - - pw.println(THREAD_COUNT + " " + readCount); - System.out.println(THREAD_COUNT + "readCount = " + readCount); + for (int count = 0; THREAD_COUNT > count; count++) { + readCount = readCount + readThread[count].getFindCount(); + readThread[count].set(false); + readThread[count] = null; + } + + pw.println(THREAD_COUNT + " " + readCount); + System.out.println(THREAD_COUNT + "readCount = " + readCount); + System.gc(); + System.out.println("-------------GC--------------"); + Thread.sleep(1000); + } + + pw.close(); } - - pw.close(); - } - static String key = "KEY"; - - public static JungleTreeEditor createTree(int deep, NodePath path, JungleTreeEditor editor) { + static String key = "KEY"; - 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++; + public static JungleTreeEditor createTree(int deep, NodePath path, JungleTreeEditor editor) { - if (deep < 12) { - editor = createTree(deep, path.add(0), editor); - editor = createTree(deep, path.add(1), 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++; + + if (deep < 12) { + editor = createTree(deep, path.add(0), editor); + editor = createTree(deep, path.add(1), editor); + } + return editor; } - return editor; - } }