Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 232:e2f7a8698c67
add BenchMark
author | tatsuki |
---|---|
date | Tue, 12 Jan 2016 22:50:00 +0900 |
parents | 48907bf43043 |
children | 036c64abd618 4b8f8fcef29e |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/benchMark/Data/TreeMapBenchMark.java src/main/java/jp/ac/u_ryukyu/ie/cr/benchMark/JungleBenchMark.java src/main/java/jp/ac/u_ryukyu/ie/cr/benchMark/persistent/DataWriteBenchMark.java src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/DefaultTest.java |
diffstat | 4 files changed, 141 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/benchMark/Data/TreeMapBenchMark.java Tue Jan 12 22:50:00 2016 +0900 @@ -0,0 +1,29 @@ +package jp.ac.u_ryukyu.ie.cr.benchMark.Data; + + +import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; + +import java.util.ArrayList; +import java.util.Collections; + +public class TreeMapBenchMark { + public static void main(String[] args) { + for (int i = 1; i <= 10; i++) { + TreeMap<Integer, Integer> map = new TreeMap<>(); + ArrayList<Integer> list = new ArrayList<>(); + + for (int count = 1; count < 100000 * i; count++) { + map = map.put(count, count); + list.add(count); + } + + Collections.shuffle(list); + long t1 = System.currentTimeMillis(); + for (Integer num : list) { + map = map.delete(num); + } + long t2 = System.currentTimeMillis(); + System.out.println((i * 100000) + " time = " + (t2 - t1)); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/benchMark/JungleBenchMark.java Tue Jan 12 22:50:00 2016 +0900 @@ -0,0 +1,58 @@ +package jp.ac.u_ryukyu.ie.cr.benchMark; + +import jp.ac.u_ryukyu.ie.cr.jungle.DefaultJungle; +import jp.ac.u_ryukyu.ie.cr.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.jungle.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.store.NodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultNodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNodeAttributes; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser; + +import java.nio.ByteBuffer; +import java.util.Iterator; + + +/** + * Created by e115731 on 15/05/07. + */ +public class JungleBenchMark { + public static void main(String args[]) { + DefaultJungle jungle = new DefaultJungle(null, "sample", new DefaultTreeEditor(new DefaultTraverser())); + jungle.createNewTree("tree"); + JungleTree tree = jungle.getTreeByName("tree"); + JungleTreeEditor editor = tree.getTreeEditor(); + NodePath path = new DefaultNodePath(); + path = path.add(0); + for (int count = 1; count <= 10; count++) { + for (int personCount = 0; personCount < 1000 * count; personCount++) { + editor = editor.replaceNewRootNode().b(); + ByteBuffer value = ByteBuffer.wrap(("p:" + personCount).getBytes()); + editor = editor.putAttribute(path, "personId", value).b(); + ByteBuffer value2 = ByteBuffer.wrap(("r:" + personCount).getBytes()); + editor = editor.putAttribute(path, "roleId", value2).b(); + } + editor.success(); + long t1 = System.currentTimeMillis(); + for (int findCount = 0; findCount < 50000; ) { + InterfaceTraverser traverser = tree.getTraverser(true); + Iterator<TreeNode> it = traverser.find(null, "personId", "p:100"); + if (it.hasNext()) { + TreeNode targetNode = it.next(); + TreeNodeAttributes attribute = targetNode.getAttributes(); + String targetRoleId = attribute.getString("roleId"); + if (targetRoleId.equals("r:100")) + findCount++; + } else { + System.out.println("find miss"); + System.exit(1); + } + } + long t2 = System.currentTimeMillis(); + System.out.println("time = " + (t2 - t1)); + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/benchMark/persistent/DataWriteBenchMark.java Tue Jan 12 22:50:00 2016 +0900 @@ -0,0 +1,33 @@ +package jp.ac.u_ryukyu.ie.cr.benchMark.persistent; + +import jp.ac.u_ryukyu.ie.cr.jungle.Jungle; +import jp.ac.u_ryukyu.ie.cr.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.jungle.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultNodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; +import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJournal; +import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJungle; + +import java.io.File; +import java.io.FileNotFoundException; + +public class DataWriteBenchMark { + + public static void main(String[] args) throws FileNotFoundException { + + PersistentJournal journal1 = new PersistentJournal(new File("./log/CommitTest.log")); + Jungle jungle = new PersistentJungle(journal1, "uuid",new DefaultTreeEditor(new DefaultTraverser())); + jungle.createNewTree("testTree"); + JungleTree tree = jungle.getTreeByName("testTree"); + JungleTreeEditor editor = tree.getTreeEditor(); + int multiple = Integer.valueOf(args[0]); + for (int count = 0 ; count < 5000 ; count++) { + editor = editor.addNewChildAt(new DefaultNodePath(),count).b(); + System.out.println(count); + } + System.out.println("success"); + editor.success(); + System.out.println("end"); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/DefaultTest.java Tue Jan 12 22:50:00 2016 +0900 @@ -0,0 +1,21 @@ +package jp.ac.u_ryukyu.ie.cr.jungle; + +import org.junit.Test; + +import java.util.TreeMap; + +/** + * Created by e115731 on 15/05/17. + */ +public class DefaultTest { + + @Test + public void Test() { + TreeMap map = new TreeMap(); + for (int i = 0; i < 10; i++) { + map.put(i, i); + } + } + + +}