private double runPerfTest(int numThreads,PerfTestRunner testRunner) throws Throwable {
  List<Thread> threads=new ArrayList<>(numThreads);
  Stopwatch stopwatch=Stopwatch.createStarted();
  for (int thread=0; thread < numThreads; thread++) {
    Thread worker=new Thread(null);
    worker.start();
    threads.add(worker);
  }
  for (  Thread worker : threads) {
    worker.join();
  }
  stopwatch.stop();
  long elapsedMillis=stopwatch.elapsed(TimeUnit.MILLISECONDS);
  double elapsedSeconds=(double)elapsedMillis / (double)1000;
  double throughput=(PERF_NUM_CANDIDATE_REQUESTS * numThreads) / elapsedSeconds;
  logger.info("Got {} requests/second",throughput);
  return throughput;
}

private double runPerfTest ( int numThreads , PerfTestRunner testRunner ) throws Throwable { List < Thread > threads = new ArrayList < > ( numThreads ) ; Stopwatch stopwatch = Stopwatch . createStarted ( ) ; for ( int thread = 0 ; thread < numThreads ; thread ++ ) { Thread worker = new Thread ( null ) ; worker . start ( ) ; threads . add ( worker ) ; } for ( Thread worker : threads ) { worker . join ( ) ; } stopwatch . stop ( ) ; long elapsedMillis = stopwatch . elapsed ( TimeUnit . MILLISECONDS ) ; double elapsedSeconds = ( double ) elapsedMillis / ( double ) 1000 ; double throughput = ( PERF_NUM_CANDIDATE_REQUESTS * numThreads ) / elapsedSeconds ; logger . info ( "Got {} requests/second" , throughput ) ; return throughput ; }
helper to run a perf test . this encapsulates teh logic of running a perf test . it creates the requested number of threads , then invokes the provided test perf_num_candidate_requests times . it returns the requests per second that result .
