예제 #1
0
  public void testThroughput(int numclients, int rounds)
      throws Exception, IOException, InterruptedException {
    this.numclients = numclients;
    this.rounds = rounds;
    timer = Timer.getCurrentTimer();
    sink = new Aggregator(numclients);

    long start = System.currentTimeMillis();
    for (int i = 0; i < numclients; i++) {
      ClientConnection cconn = new ClientConnection(this, iaddr, rounds);
      clients.put(cconn.id, cconn);
      try {
        CallbackFuture.getFrom(cconn); // wait connection to connect
      } catch (Exception e) {
        System.err.println("conn " + i + " failed:" + e);
        return;
      }
      //            Thread.sleep(2);
    }
    out.println("Started clients:" + numclients);
    double avgLatency = sink.avg.get();
    float time = (System.currentTimeMillis() - start) / 1000.0f; // sec
    float rate = numclients * rounds / time;
    out.printf("Elapsed=%f sec; throughput = %f roundtrips/sec \n", time, rate);
    out.printf("Latency=%f msec \n", avgLatency);
    timer.shutdown().get();
    out.println("============================== test finished");
  }
예제 #2
0
 @Override
 protected void complete() throws Exception {
   avg.post(sum / counter);
 }