@Test
public void doSelect() throws Exception {

    WeightConsistentHashLoadBalancer loadBalancer = new WeightConsistentHashLoadBalancer(null);
    Map<Integer, Integer> cnt = new HashMap<Integer, Integer>(40);
    int size = 20;
    int total = 100000;
    SofaRequest request = new SofaRequest();
    request.setInterfaceName(ConsistentHashLoadBalancerTest.class.getName());
    request.setMethod(ConsistentHashLoadBalancerTest.class.getMethod("doSelect"));
    for (int i = 0; i < size; i++) {
        cnt.put(9000 + i, 0);
    }
    List<ProviderInfo> providers = buildDiffWeightProviderList(size);
    long start = System.currentTimeMillis();
    for (int i = 0; i < total; i++) {
        ProviderInfo provider = loadBalancer.doSelect(request, providers);
        int port = provider.getPort();
        cnt.put(port, cnt.get(port) + 1);
    }
    long end = System.currentTimeMillis();
    System.out.println("elapsed" + (end - start) + "ms");
    System.out.println("avg " + (end - start) * 1000 * 1000 / total + "ns");
    int count = 0;
    for (int i = 0; i < size; i++) {
        if (cnt.get(9000 + i) > 0) {
            count++;
        }
    }
    // 应该落在同一台机器上
    Assert.assertTrue(count == 1);
}