changeset 191:d484151bc420

change TreeMapBenchMark serch attribtue
author tatsuki
date Thu, 30 Apr 2015 06:30:26 +0900
parents a01507a9f826
children 35f3be8d9ffe
files src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TatsukiTreeMapGetThread.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/UtilTreeMapGetThread.java
diffstat 3 files changed, 15 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TatsukiTreeMapGetThread.java	Tue Apr 21 17:28:20 2015 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TatsukiTreeMapGetThread.java	Thu Apr 30 06:30:26 2015 +0900
@@ -2,7 +2,6 @@
 
 import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap;
 
-import java.util.Iterator;
 import java.util.Optional;
 
 
@@ -10,7 +9,7 @@
  * Created by e115731 on 15/03/17.
  */
 public class TatsukiTreeMapGetThread extends AbstractTreeMapThread {
-    TreeMap<String, String> map;
+    TreeMap<Long, String> map;
     private long findCount;
     boolean loop = true;
 
@@ -32,9 +31,11 @@
     @Override
     public void run() {
         while (loop) {
-           Optional<String> value  = map.get("50");
-                if (value.isPresent())
-                    findCount++;
+            Optional<String> value = map.get(findCount % 1000);
+            if (value.isPresent())
+                findCount++;
+            else
+                System.out.println("miss");
         }
     }
 }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TreeMapBenchMark.java	Tue Apr 21 17:28:20 2015 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TreeMapBenchMark.java	Thu Apr 30 06:30:26 2015 +0900
@@ -1,10 +1,5 @@
 package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.test;
 
-import fj.Ord;
-import fj.data.TreeMap;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.ParserConfigurationException;
 import java.io.*;
 
 /**
@@ -12,7 +7,6 @@
  */
 public class TreeMapBenchMark {
     public static void main(String[] args) throws InterruptedException, IOException {
-        Thread.sleep(5000);
 
         if (args.length == 0) {
             System.out.println("args get or getLoop or list");
@@ -32,18 +26,10 @@
 
             readThread = new AbstractTreeMapThread[THREAD_COUNT];
 
-            if (args[0].equals("fj")) {
-                TreeMap<String, String> map = TreeMap.empty(Ord.stringOrd);
-                for (int count = 0; count < 1000; count++) {
-                    map = map.set(String.valueOf(count), String.valueOf(count));
-                }
-                for (int count = 0; THREAD_COUNT > count; count++) {
-                    readThread[count] = new FJTreeMapGetLoopThread(map);
-                }
-            } else if (args[0].equals("util")) {
+            if (args[0].equals("util")) {
                 java.util.TreeMap map = new java.util.TreeMap();
-                for (int count = 0; count < 1000; count++) {
-                    map.put(String.valueOf(count), String.valueOf(count));
+                for (long count = 0; count < 1000; count++) {
+                    map.put(count, String.valueOf(count));
                 }
 
                 for (int count = 0; THREAD_COUNT > count; count++) {
@@ -51,8 +37,8 @@
                 }
             } else if (args[0].equals("tatsuki")) {
                 jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap map = new jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap();
-                for (int count = 0; count < 1000; count++) {
-                    map = map.put(String.valueOf(count), String.valueOf(count));
+                for (long count = 0; count < 1000; count++) {
+                    map = map.put(count, String.valueOf(count));
                 }
 
                 for (int count = 0; THREAD_COUNT > count; count++) {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/UtilTreeMapGetThread.java	Tue Apr 21 17:28:20 2015 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/UtilTreeMapGetThread.java	Thu Apr 30 06:30:26 2015 +0900
@@ -6,7 +6,7 @@
  * Created by e115731 on 15/04/18.
  */
 public class UtilTreeMapGetThread extends AbstractTreeMapThread {
-    TreeMap<String, String> map;
+    TreeMap<Long, String> map;
     private long findCount;
     boolean loop = true;
 
@@ -28,9 +28,11 @@
     @Override
     public void run() {
         while (loop) {
-            String value = map.get("50");
+            String value = map.get(findCount % 1000);
             if (value != null)
                 findCount++;
+            else
+                System.out.println("miss");
         }
     }
 }
\ No newline at end of file