You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2010/11/08 20:53:45 UTC
svn commit: r1032680 -
/httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/
Author: olegk
Date: Mon Nov 8 19:53:44 2010
New Revision: 1032680
URL: http://svn.apache.org/viewvc?rev=1032680&view=rev
Log:
TABS -> SPACES
Modified:
httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Benchmark.java
httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Stats.java
httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient3.java
httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java
httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpCore.java
httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpJRE.java
httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestJettyHttpClient.java
httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestNingHttpClient.java
Modified: httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Benchmark.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Benchmark.java?rev=1032680&r1=1032679&r2=1032680&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Benchmark.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Benchmark.java Mon Nov 8 19:53:44 2010
@@ -47,20 +47,21 @@ import org.eclipse.jetty.util.thread.Que
public class Benchmark {
public static void main(String[] args) throws Exception {
-
+
String ns = System.getProperty("hc.benchmark.n-requests", "200000");
String nc = System.getProperty("hc.benchmark.concurrent", "100");
String cls = System.getProperty("hc.benchmark.content-len", "2048");
-
+
int n = Integer.parseInt(ns);
int c = Integer.parseInt(nc);
int contentLen = Integer.parseInt(cls);
-
+
SocketConnector connector = new SocketConnector();
connector.setPort(0);
connector.setRequestBufferSize(12 * 1024);
connector.setResponseBufferSize(12 * 1024);
connector.setAcceptors(2);
+ connector.setAcceptQueueSize(c);
QueuedThreadPool threadpool = new QueuedThreadPool();
threadpool.setMinThreads(c);
@@ -76,7 +77,7 @@ public class Benchmark {
// Sleep a little
Thread.sleep(2000);
-
+
TestHttpAgent[] agents = new TestHttpAgent[] {
new TestHttpClient3(),
new TestHttpJRE(),
Modified: httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Stats.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Stats.java?rev=1032680&r1=1032679&r2=1032680&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Stats.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Stats.java Mon Nov 8 19:53:44 2010
@@ -31,7 +31,7 @@ public class Stats {
private final int expectedCount;
private final int concurrency;
-
+
private int successCount = 0;
private int failureCount = 0;
private long contentLen = 0;
@@ -48,7 +48,7 @@ public class Stats {
}
public synchronized void success(long contentLen) {
- if (isComplete()) return;
+ if (isComplete()) return;
this.successCount++;
this.contentLen = contentLen;
this.totalContentLen += contentLen;
@@ -56,7 +56,7 @@ public class Stats {
}
public synchronized void failure(long contentLen) {
- if (isComplete()) return;
+ if (isComplete()) return;
this.failureCount++;
this.contentLen = contentLen;
this.totalContentLen += contentLen;
@@ -66,7 +66,7 @@ public class Stats {
public int getConcurrency() {
return this.concurrency;
}
-
+
public synchronized int getSuccessCount() {
return successCount;
}
@@ -86,7 +86,7 @@ public class Stats {
public synchronized long getTotalContentLen() {
return totalContentLen;
}
-
+
public synchronized void waitFor() throws InterruptedException {
while (!isComplete()) {
wait();
Modified: httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient3.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient3.java?rev=1032680&r1=1032679&r2=1032680&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient3.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient3.java Mon Nov 8 19:53:44 2010
@@ -46,7 +46,7 @@ public class TestHttpClient3 implements
public TestHttpClient3() {
super();
- this.mgr = new MultiThreadedHttpConnectionManager();
+ this.mgr = new MultiThreadedHttpConnectionManager();
this.httpclient = new HttpClient(this.mgr);
this.httpclient.getParams().setVersion(
HttpVersion.HTTP_1_1);
@@ -55,13 +55,13 @@ public class TestHttpClient3 implements
this.httpclient.getHttpConnectionManager().getParams()
.setStaleCheckingEnabled(false);
this.httpclient.getParams().setSoTimeout(15000);
-
+
HttpMethodRetryHandler retryhandler = new HttpMethodRetryHandler() {
public boolean retryMethod(final HttpMethod httpmethod, final IOException ex, int count) {
return false;
}
-
+
};
this.httpclient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryhandler); }
@@ -88,20 +88,20 @@ public class TestHttpClient3 implements
}
return stats;
}
-
+
class WorkerThread extends Thread {
private final Stats stats;
private final URI target;
private final byte[] content;
-
+
WorkerThread(final Stats stats, final URI target, final byte[] content) {
super();
this.stats = stats;
this.target = target;
this.content = content;
}
-
+
@Override
public void run() {
byte[] buffer = new byte[4096];
@@ -133,7 +133,7 @@ public class TestHttpClient3 implements
}
}
}
-
+
}
public Stats get(final URI target, int n, int c) throws Exception {
Modified: httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java?rev=1032680&r1=1032679&r2=1032680&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java Mon Nov 8 19:53:44 2010
@@ -66,7 +66,7 @@ public class TestHttpClient4 implements
false);
params.setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE,
8 * 1024);
- params.setIntParameter(HttpConnectionParams.SO_TIMEOUT,
+ params.setIntParameter(HttpConnectionParams.SO_TIMEOUT,
15000);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
@@ -74,12 +74,12 @@ public class TestHttpClient4 implements
this.mgr = new ThreadSafeClientConnManager(schemeRegistry);
this.httpclient = new DefaultHttpClient(this.mgr, params);
this.httpclient.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
-
+
public boolean retryRequest(
final IOException exception, int executionCount, final HttpContext context) {
return false;
}
-
+
});
}
@@ -106,20 +106,20 @@ public class TestHttpClient4 implements
}
return stats;
}
-
+
class WorkerThread extends Thread {
private final Stats stats;
private final URI target;
private final byte[] content;
-
+
WorkerThread(final Stats stats, final URI target, final byte[] content) {
super();
this.stats = stats;
this.target = target;
this.content = content;
}
-
+
@Override
public void run() {
byte[] buffer = new byte[4096];
@@ -158,9 +158,9 @@ public class TestHttpClient4 implements
}
}
}
-
+
}
-
+
public Stats get(final URI target, int n, int c) throws Exception {
return execute(target, null, n ,c);
}
Modified: httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpCore.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpCore.java?rev=1032680&r1=1032679&r2=1032680&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpCore.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpCore.java Mon Nov 8 19:53:44 2010
@@ -78,7 +78,7 @@ public class TestHttpCore implements Tes
false);
this.params.setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE,
8 * 1024);
- this.params.setIntParameter(HttpConnectionParams.SO_TIMEOUT,
+ this.params.setIntParameter(HttpConnectionParams.SO_TIMEOUT,
15000);
this.httpproc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
@@ -108,7 +108,7 @@ public class TestHttpCore implements Tes
buffer.append(target.getQuery());
}
String requestUri = buffer.toString();
-
+
Stats stats = new Stats(n, c);
WorkerThread[] workers = new WorkerThread[c];
for (int i = 0; i < workers.length; i++) {
@@ -129,8 +129,8 @@ public class TestHttpCore implements Tes
private final HttpHost targetHost;
private final String requestUri;
private final byte[] content;
-
- WorkerThread(final Stats stats,
+
+ WorkerThread(final Stats stats,
final HttpHost targetHost, final String requestUri, final byte[] content) {
super();
this.stats = stats;
@@ -138,7 +138,7 @@ public class TestHttpCore implements Tes
this.requestUri = requestUri;
this.content = content;
}
-
+
@Override
public void run() {
byte[] buffer = new byte[4096];
@@ -165,7 +165,7 @@ public class TestHttpCore implements Tes
this.targetHost.getPort() > 0 ? this.targetHost.getPort() : 80);
conn.bind(socket, params);
}
-
+
context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, targetHost);
@@ -208,9 +208,9 @@ public class TestHttpCore implements Tes
} catch (IOException ignore) {}
}
}
-
+
}
-
+
public Stats get(final URI target, int n, int c) throws Exception {
return execute(target, null, n, c);
}
Modified: httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpJRE.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpJRE.java?rev=1032680&r1=1032679&r2=1032680&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpJRE.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpJRE.java Mon Nov 8 19:53:44 2010
@@ -66,14 +66,14 @@ public class TestHttpJRE implements Test
private final Stats stats;
private final URL target;
private final byte[] content;
-
+
WorkerThread(final Stats stats, final URL target, final byte[] content) {
super();
this.stats = stats;
this.target = target;
this.content = content;
}
-
+
@Override
public void run() {
byte[] buffer = new byte[4096];
@@ -119,7 +119,7 @@ public class TestHttpJRE implements Test
}
}
}
-
+
public Stats get(final URI target, int n, int c) throws Exception {
return execute(target, null, n, c);
}
Modified: httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestJettyHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestJettyHttpClient.java?rev=1032680&r1=1032679&r2=1032680&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestJettyHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestJettyHttpClient.java Mon Nov 8 19:53:44 2010
@@ -98,7 +98,7 @@ public class TestJettyHttpClient impleme
super();
this.stats = stats;
}
-
+
protected void onResponseStatus(
final Buffer version, int status, final Buffer reason) throws IOException {
this.status = status;
@@ -132,7 +132,7 @@ public class TestJettyHttpClient impleme
this.stats.failure(this.contentLen);
super.onException(x);
}
-
+
};
public static void main(String[] args) throws Exception {
@@ -146,7 +146,7 @@ public class TestJettyHttpClient impleme
if (args.length > 2) {
c = Integer.parseInt(args[2]);
}
-
+
TestJettyHttpClient test = new TestJettyHttpClient();
test.init();
try {
Modified: httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestNingHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestNingHttpClient.java?rev=1032680&r1=1032679&r2=1032680&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestNingHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestNingHttpClient.java Mon Nov 8 19:53:44 2010
@@ -61,7 +61,7 @@ public class TestNingHttpClient implemen
.setMaximumConnectionsPerHost(c)
.setMaximumConnectionsTotal(2000)
.setRequestTimeoutInMs(15000)
- .build();
+ .build();
this.client = new AsyncHttpClient(config);
Stats stats = new Stats(n, c);
@@ -70,11 +70,11 @@ public class TestNingHttpClient implemen
Request request;
if (content == null) {
request = this.client.prepareGet(targetURI.toASCIIString())
- .build();
+ .build();
} else {
request = this.client.preparePost(targetURI.toASCIIString())
.setBody(content)
- .build();
+ .build();
}
try {
this.client.executeRequest(request, new SimpleAsyncHandler(stats));
@@ -94,7 +94,7 @@ public class TestNingHttpClient implemen
}
public String getClientName() {
- return "Ning Async HTTP client 1.3";
+ return "Ning Async HTTP client 1.3";
}
static class SimpleAsyncHandler implements AsyncHandler<Object> {
@@ -107,7 +107,7 @@ public class TestNingHttpClient implemen
super();
this.stats = stats;
}
-
+
public STATE onStatusReceived(final HttpResponseStatus responseStatus) throws Exception {
this.status = responseStatus.getStatusCode();
return STATE.CONTINUE;
@@ -148,7 +148,7 @@ public class TestNingHttpClient implemen
if (args.length > 2) {
c = Integer.parseInt(args[2]);
}
-
+
TestNingHttpClient test = new TestNingHttpClient();
test.init();
try {