List of usage examples for org.apache.http.contrib.benchmark BenchmarkWorker BenchmarkWorker
public BenchmarkWorker(final HttpParams params, int verbosity, final HttpRequest request, final HttpHost targetHost, int count, boolean keepalive)
From source file:org.apache.http.contrib.benchmark.HttpBenchmark.java
private void execute() { prepare();/*from w w w . j a v a 2s. co m*/ ThreadPoolExecutor workerPool = new ThreadPoolExecutor(threads, threads, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory() { public Thread newThread(Runnable r) { return new Thread(r, "ClientPool"); } }); workerPool.prestartAllCoreThreads(); BenchmarkWorker[] workers = new BenchmarkWorker[threads]; for (int i = 0; i < threads; i++) { workers[i] = new BenchmarkWorker(params, verbosity, request[i], host, requests, keepAlive); workerPool.execute(workers[i]); } while (workerPool.getCompletedTaskCount() < threads) { Thread.yield(); try { Thread.sleep(1000); } catch (InterruptedException ignore) { } } workerPool.shutdown(); ResultProcessor.printResults(workers, host, url.toString(), contentLength); }