hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1464572 - in /httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark: Benchmark.java httpcore/RandomDataHandler.java jetty/RandomDataHandler.java
Date Thu, 04 Apr 2013 14:37:27 GMT
Author: olegk
Date: Thu Apr  4 14:37:27 2013
New Revision: 1464572

URL: http://svn.apache.org/r1464572
Log:
Increased number of default threads / requests; made blocking handlers more consistent with
non-blocking ones

Modified:
    httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/Benchmark.java
    httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/RandomDataHandler.java
    httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/RandomDataHandler.java

Modified: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/Benchmark.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/Benchmark.java?rev=1464572&r1=1464571&r2=1464572&view=diff
==============================================================================
--- httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/Benchmark.java
(original)
+++ httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/Benchmark.java
Thu Apr  4 14:37:27 2013
@@ -58,8 +58,8 @@ public class Benchmark {
             CommandLineUtils.parseCommandLine(cmd, config);
         } else {
             config.setKeepAlive(true);
-            config.setRequests(50000);
-            config.setThreads(25);
+            config.setRequests(100000);
+            config.setThreads(50);
         }
 
         final URL target = new URL("http", "localhost", PORT, "/rnd?c=2048");
@@ -69,8 +69,8 @@ public class Benchmark {
         benchmark.run(new JettyServer(PORT), config);
         benchmark.run(new HttpCoreServer(PORT), config);
         benchmark.run(new JettyNIOServer(PORT), config);
-        benchmark.run(new NettyNIOServer(PORT), config);
         benchmark.run(new HttpCoreNIOServer(PORT), config);
+        benchmark.run(new NettyNIOServer(PORT), config);
     }
 
     public Benchmark() {
@@ -96,6 +96,7 @@ public class Benchmark {
             final HttpBenchmark benchmark = new HttpBenchmark(config);
             benchmark.execute();
             System.out.println("---------------------------------------------------------------");
+            Thread.sleep(3000);
         } finally {
             server.shutdown();
         }

Modified: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/RandomDataHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/RandomDataHandler.java?rev=1464572&r1=1464571&r2=1464572&view=diff
==============================================================================
--- httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/RandomDataHandler.java
(original)
+++ httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/RandomDataHandler.java
Thu Apr  4 14:37:27 2013
@@ -51,6 +51,7 @@ class RandomDataHandler implements HttpR
         super();
     }
 
+    @Override
     public void handle(
             final HttpRequest request,
             final HttpResponse response,
@@ -94,37 +95,37 @@ class RandomDataHandler implements HttpR
         public RandomEntity(final int count) {
             super();
             this.count = count;
-            this.buf = new byte[1024];
+            this.buf = new byte[count];
+            final int r = Math.abs(this.buf.hashCode());
+            for (int i = 0; i < count; i++) {
+                this.buf[i] = (byte) ((r + i) % 96 + 32);
+            }
             setContentType("text/plain");
         }
 
+        @Override
         public InputStream getContent() throws IOException, IllegalStateException {
             throw new IllegalStateException("Method not supported");
         }
 
+        @Override
         public long getContentLength() {
             return this.count;
         }
 
+        @Override
         public boolean isRepeatable() {
             return true;
         }
 
+        @Override
         public boolean isStreaming() {
             return false;
         }
 
+        @Override
         public void writeTo(final OutputStream outstream) throws IOException {
-            final int r = Math.abs(this.buf.hashCode());
-            int remaining = this.count;
-            while (remaining > 0) {
-                final int chunk = Math.min(this.buf.length, remaining);
-                for (int i = 0; i < chunk; i++) {
-                    this.buf[i] = (byte) ((r + i) % 96 + 32);
-                }
-                outstream.write(this.buf, 0, chunk);
-                remaining -= chunk;
-            }
+            outstream.write(this.buf);
         }
 
     }

Modified: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/RandomDataHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/RandomDataHandler.java?rev=1464572&r1=1464571&r2=1464572&view=diff
==============================================================================
--- httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/RandomDataHandler.java
(original)
+++ httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/RandomDataHandler.java
Thu Apr  4 14:37:27 2013
@@ -44,6 +44,7 @@ class RandomDataHandler extends Abstract
         super();
     }
 
+    @Override
     public void handle(
             final String target,
             final Request baseRequest,
@@ -79,18 +80,14 @@ class RandomDataHandler extends Abstract
         response.setContentType("text/plain");
         response.setContentLength(count);
 
-        final OutputStream outstream = response.getOutputStream();
-        final byte[] tmp = new byte[1024];
-        final int r = Math.abs(tmp.hashCode());
-        int remaining = count;
-        while (remaining > 0) {
-            final int chunk = Math.min(tmp.length, remaining);
-            for (int i = 0; i < chunk; i++) {
-                tmp[i] = (byte) ((r + i) % 96 + 32);
-            }
-            outstream.write(tmp, 0, chunk);
-            remaining -= chunk;
+        final byte[] b = new byte[count];
+        final int r = Math.abs(b.hashCode());
+        for (int i = 0; i < count; i++) {
+            b[i] = (byte) ((r + i) % 96 + 32);
         }
+        
+        final OutputStream outstream = response.getOutputStream();
+        outstream.write(b);
         outstream.flush();
     }
 



Mime
View raw message