作者 crossoverJie

:white_check_mark: Adding tests.性能测试 treeMap 确实要由于排序Map

... ... @@ -3,7 +3,7 @@ package com.crossoverjie.cim.common.route.algorithm.consistenthash;
import com.crossoverjie.cim.common.data.construct.SortArrayMap;
/**
* Function:
* Function:自定义排序 Map 实现
*
* @author crossoverJie
* Date: 2019-02-27 00:38
... ... @@ -21,7 +21,6 @@ public class SortArrayMapConsistentHash extends AbstractConsistentHash {
@Override
public void sort() {
sortArrayMap.sort();
sortArrayMap.print();
}
@Override
... ...
... ... @@ -4,7 +4,7 @@ import java.util.SortedMap;
import java.util.TreeMap;
/**
* Function:
* Function:TreeMap 实现
*
* @author crossoverJie
* Date: 2019-02-27 01:16
... ...
... ... @@ -2,6 +2,8 @@ package com.crossoverjie.cim.common.data.construct;
import org.junit.Test;
import java.util.TreeMap;
public class SortArrayMapTest {
@Test
... ... @@ -154,4 +156,18 @@ public class SortArrayMapTest {
System.out.println("不排耗时 " + (end -star));
System.out.println(map.size());
}
@Test
public void add7(){
TreeMap<Long,String> treeMap = new TreeMap<Long, String>() ;
long star = System.currentTimeMillis() ;
for (int i = 0; i < count; i++) {
double d = Math.random();
int ran = (int)(d*100);
treeMap.put(Long.valueOf(i + ran) ,"127.0.0." + i);
}
long end = System.currentTimeMillis() ;
System.out.println("耗时 " + (end -star));
System.out.println(treeMap.size());
}
}
\ No newline at end of file
... ...
... ... @@ -27,8 +27,11 @@ app.zk.root=/route
#路由策略,一致性 hash
app.route.way=com.crossoverjie.cim.common.route.algorithm.consistenthash.ConsistentHashHandle
#一致性 hash 算法具体实现
app.route.way.consitenthash=com.crossoverjie.cim.common.route.algorithm.consistenthash.SortArrayMapConsistentHash
#一致性 hash 算法具体实现--自定义有序 map
#app.route.way.consitenthash=com.crossoverjie.cim.common.route.algorithm.consistenthash.SortArrayMapConsistentHash
#一致性 hash 算法具体实现--TreeMap
app.route.way.consitenthash=com.crossoverjie.cim.common.route.algorithm.consistenthash.TreeMapConsistentHash
# Redis 配置
spring.redis.host=47.98.194.60
... ...