Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 181:7282ee629af3
add miss
author | tatsuki |
---|---|
date | Tue, 17 Mar 2015 15:38:27 +0900 |
parents | 2e6ca84686da |
children | 89898b455ebc |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/ReadTreeThread.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TreeMapBenchMark.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/benchmark.java |
diffstat | 4 files changed, 124 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java Tue Mar 17 14:08:40 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java Tue Mar 17 15:38:27 2015 +0900 @@ -55,7 +55,7 @@ } }; - System.out.println("transaction"); + InterfaceTraverser traverser = new InterfaceTraverser(newRoot, true); traverser.createIndex(); TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> index = traverser.getIndex();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/ReadTreeThread.java Tue Mar 17 15:38:27 2015 +0900 @@ -0,0 +1,38 @@ +package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.test; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; + +/** + * Created by e115731 on 15/03/14. + */ +public class ReadTreeThread extends JungleBenchMarkThread { + + JungleTree tree; + private long findCount; + + boolean loop = true; + + public ReadTreeThread(JungleTree tree) { + this.tree = tree; + this.findCount = 0; + } + + public long getFindCount() { + System.out.println("thread count = " + findCount); + return findCount; + } + + public void set(boolean loop) { + this.loop = loop; + } + + @Override + public void run() { + while (loop) { + TreeNode root = tree.getRootNode(); + if (root != null) + findCount++; + } + } +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TreeMapBenchMark.java Tue Mar 17 14:08:40 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TreeMapBenchMark.java Tue Mar 17 15:38:27 2015 +0900 @@ -22,7 +22,7 @@ Runtime rt = Runtime.getRuntime(); int cpuNum = rt.availableProcessors(); - File file = new File("./time//get" + args[0] + "TreeMapTime"); + File file = new File("./time/get" + args[0] + "TreeMapTime"); PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/benchmark.java Tue Mar 17 15:38:27 2015 +0900 @@ -0,0 +1,84 @@ +package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.test; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; +import org.xml.sax.SAXException; + +import javax.xml.parsers.ParserConfigurationException; +import java.io.*; +import java.nio.ByteBuffer; + +/** + * Created by e115731 on 15/03/16. + */ +public class benchmark { + + public static void main(String[] args) throws InterruptedException, IOException, ParserConfigurationException, SAXException { + System.out.println("startRead"); + + if (args.length == 0) { + System.out.println("args root or attribute"); + System.exit(0); + } + + Runtime rt = Runtime.getRuntime(); + int cpuNum = rt.availableProcessors(); + + DefaultJungle jungle = new DefaultJungle(null,"sample", new DefaultTreeEditor(new DefaultTraverser())); + jungle.createNewTree("hoge"); + JungleTree tree = jungle.getTreeByName("hoge"); + JungleTreeEditor editor = tree.getTreeEditor(); + editor = editor.putAttribute(new DefaultNodePath(), "test", ByteBuffer.wrap("test".getBytes())).b(); + editor.success(); + + + File file = new File("./time/readTree" + args[0]); + PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); + + for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) { + + JungleBenchMarkThread readThread[] = null; + + if (args[0].equals("root")) { + readThread = new ReadTreeThread[THREAD_COUNT]; + for (int count = 0; THREAD_COUNT > count; count++) { + readThread[count] = new ReadTreeThread(tree); + } + } + else if (args[0].equals("attribute")) { + readThread = new readTreeAttributeThread[THREAD_COUNT]; + for (int count = 0; THREAD_COUNT > count; count++) { + readThread[count] = new readTreeAttributeThread(tree); + } + } else { + System.out.println("not allow arg"); + System.exit(0); + } + + for (int count = 0; THREAD_COUNT > count; count++) { + readThread[count].start(); + } + + System.out.println("StartThread"); + + Thread.sleep(1000); + long 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); + } + + pw.close(); + } + +} +