diff --git a/httpclient-benchmark/pom.xml b/httpclient-benchmark/pom.xml
index bd2fc0fd3..a5d37a6ab 100644
--- a/httpclient-benchmark/pom.xml
+++ b/httpclient-benchmark/pom.xml
@@ -40,6 +40,18 @@
http://hc.apache.org/httpcomponents-clientjar
+
+
+ jboss
+ JBoss Repository
+ default
+ http://oss.sonatype.org/content/repositories/releases
+
+ false
+
+
+
+
org.apache.httpcomponents
@@ -83,6 +95,12 @@
1.5.10compile
+
+ com.ning
+ async-http-client
+ 1.3.3
+ compile
+
diff --git a/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Benchmark.java b/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Benchmark.java
index dd53ec39a..f5d6b7c61 100644
--- a/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Benchmark.java
+++ b/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/Benchmark.java
@@ -48,8 +48,8 @@ public class Benchmark {
public static void main(String[] args) throws Exception {
- String ns = System.getProperty("hc.benchmark.n-requests", "100000");
- String nc = System.getProperty("hc.benchmark.concurrent", "25");
+ 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);
@@ -82,7 +82,8 @@ public class Benchmark {
new TestHttpJRE(),
new TestHttpCore(),
new TestHttpClient4(),
- new TestJettyHttpClient()
+ new TestJettyHttpClient(),
+ new TestNingHttpClient()
};
byte[] content = new byte[contentLen];
diff --git a/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestJettyHttpClient.java b/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestJettyHttpClient.java
index c50f19223..e6d8be2b8 100644
--- a/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestJettyHttpClient.java
+++ b/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestJettyHttpClient.java
@@ -107,7 +107,7 @@ public class TestJettyHttpClient implements TestHttpAgent {
@Override
protected void onResponseContent(final Buffer content) throws IOException {
- this.contentLen += content.length();
+ this.contentLen += content.asArray().length;
super.onResponseContent(content);
}
diff --git a/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestNingHttpClient.java b/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestNingHttpClient.java
new file mode 100644
index 000000000..8fb390efe
--- /dev/null
+++ b/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestNingHttpClient.java
@@ -0,0 +1,165 @@
+/*
+ * ====================================================================
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+package org.apache.http.client.benchmark;
+
+import java.io.IOException;
+import java.net.URI;
+
+import com.ning.http.client.AsyncHandler;
+import com.ning.http.client.AsyncHttpClient;
+import com.ning.http.client.AsyncHttpClientConfig;
+import com.ning.http.client.HttpResponseBodyPart;
+import com.ning.http.client.HttpResponseHeaders;
+import com.ning.http.client.HttpResponseStatus;
+import com.ning.http.client.Request;
+
+public class TestNingHttpClient implements TestHttpAgent {
+
+ private AsyncHttpClient client;
+
+ public TestNingHttpClient() {
+ super();
+ }
+
+ public void init() throws Exception {
+ }
+
+ public void shutdown() throws Exception {
+ this.client.close();
+ }
+
+ Stats execute(final URI targetURI, byte[] content, int n, int c) throws Exception {
+ if (this.client != null) {
+ this.client.close();
+ }
+ AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder()
+ .setKeepAlive(true)
+ .setCompressionEnabled(false)
+ .setMaximumConnectionsPerHost(c)
+ .setMaximumConnectionsTotal(2000)
+ .setRequestTimeoutInMs(15000)
+ .build();
+ this.client = new AsyncHttpClient(config);
+
+ Stats stats = new Stats(n, c);
+
+ for (int i = 0; i < n; i++) {
+ Request request;
+ if (content == null) {
+ request = this.client.prepareGet(targetURI.toASCIIString())
+ .build();
+ } else {
+ request = this.client.preparePost(targetURI.toASCIIString())
+ .setBody(content)
+ .build();
+ }
+ try {
+ this.client.executeRequest(request, new SimpleAsyncHandler(stats));
+ } catch (IOException ex) {
+ }
+ }
+ stats.waitFor();
+ return stats;
+ }
+
+ public Stats get(final URI target, int n, int c) throws Exception {
+ return execute(target, null, n, c);
+ }
+
+ public Stats post(final URI target, byte[] content, int n, int c) throws Exception {
+ return execute(target, content, n, c);
+ }
+
+ public String getClientName() {
+ return "Ning Async HTTP client 1.3";
+ }
+
+ static class SimpleAsyncHandler implements AsyncHandler