hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1480206 - in /httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark: Stats.java TestApacheHttpClient.java TestHttpJRE.java
Date Wed, 08 May 2013 09:45:40 GMT
Author: olegk
Date: Wed May  8 09:45:39 2013
New Revision: 1480206

URL: http://svn.apache.org/r1480206
Log:
Code cleanups

Modified:
    httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/Stats.java
    httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/TestApacheHttpClient.java
    httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/TestHttpJRE.java

Modified: httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/Stats.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/Stats.java?rev=1480206&r1=1480205&r2=1480206&view=diff
==============================================================================
--- httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/Stats.java
(original)
+++ httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/Stats.java
Wed May  8 09:45:39 2013
@@ -48,7 +48,9 @@ public class Stats {
     }
 
     public synchronized void success(final long contentLen) {
-        if (isComplete()) return;
+        if (isComplete()) {
+            return;
+        }
         this.successCount++;
         this.contentLen = contentLen;
         this.totalContentLen += contentLen;
@@ -56,7 +58,9 @@ public class Stats {
     }
 
     public synchronized void failure(final long contentLen) {
-        if (isComplete()) return;
+        if (isComplete()) {
+            return;
+        }
         this.failureCount++;
         this.contentLen = contentLen;
         this.totalContentLen += contentLen;

Modified: httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/TestApacheHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/TestApacheHttpClient.java?rev=1480206&r1=1480205&r2=1480206&view=diff
==============================================================================
--- httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/TestApacheHttpClient.java
(original)
+++ httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/TestApacheHttpClient.java
Wed May  8 09:45:39 2013
@@ -49,11 +49,11 @@ public class TestApacheHttpClient implem
 
     public TestApacheHttpClient() {
         super();
-        ConnectionConfig connectionConfig = ConnectionConfig.custom()
+        final ConnectionConfig connectionConfig = ConnectionConfig.custom()
                 .setBufferSize(8 * 1024)
                 .setFragmentSizeHint(8 * 1024)
                 .build();
-        SocketConfig socketConfig = SocketConfig.custom()
+        final SocketConfig socketConfig = SocketConfig.custom()
                 .setSoTimeout(15000)
                 .build();
         this.mgr = new PoolingHttpClientConnectionManager();
@@ -74,16 +74,16 @@ public class TestApacheHttpClient implem
     Stats execute(final URI target, final byte[] content, final int n, final int c) throws
Exception {
         this.mgr.setMaxTotal(2000);
         this.mgr.setDefaultMaxPerRoute(c);
-        Stats stats = new Stats(n, c);
-        WorkerThread[] workers = new WorkerThread[c];
+        final Stats stats = new Stats(n, c);
+        final WorkerThread[] workers = new WorkerThread[c];
         for (int i = 0; i < workers.length; i++) {
             workers[i] = new WorkerThread(stats, target, content);
         }
-        for (int i = 0; i < workers.length; i++) {
-            workers[i].start();
+        for (final WorkerThread worker : workers) {
+            worker.start();
         }
-        for (int i = 0; i < workers.length; i++) {
-            workers[i].join();
+        for (final WorkerThread worker : workers) {
+            worker.join();
         }
         return stats;
     }
@@ -103,23 +103,23 @@ public class TestApacheHttpClient implem
 
         @Override
         public void run() {
-            byte[] buffer = new byte[4096];
+            final byte[] buffer = new byte[4096];
             while (!this.stats.isComplete()) {
                 HttpUriRequest request;
                 if (this.content == null) {
-                    HttpGet httpget = new HttpGet(target);
+                    final HttpGet httpget = new HttpGet(target);
                     request = httpget;
                 } else {
-                    HttpPost httppost = new HttpPost(target);
+                    final HttpPost httppost = new HttpPost(target);
                     httppost.setEntity(new ByteArrayEntity(content));
                     request = httppost;
                 }
                 long contentLen = 0;
                 try {
-                    HttpResponse response = httpclient.execute(request);
-                    HttpEntity entity = response.getEntity();
+                    final HttpResponse response = httpclient.execute(request);
+                    final HttpEntity entity = response.getEntity();
                     if (entity != null) {
-                        InputStream instream = entity.getContent();
+                        final InputStream instream = entity.getContent();
                         contentLen = 0;
                         if (instream != null) {
                             try {
@@ -137,7 +137,7 @@ public class TestApacheHttpClient implem
                     } else {
                         this.stats.failure(contentLen);
                     }
-                } catch (IOException ex) {
+                } catch (final IOException ex) {
                     this.stats.failure(contentLen);
                     request.abort();
                 }
@@ -158,7 +158,7 @@ public class TestApacheHttpClient implem
 
     @Override
     public String getClientName() {
-        VersionInfo vinfo = VersionInfo.loadVersionInfo("org.apache.http.client",
+        final VersionInfo vinfo = VersionInfo.loadVersionInfo("org.apache.http.client",
                 Thread.currentThread().getContextClassLoader());
         return "Apache HttpClient 4 (ver: " +
             ((vinfo != null) ? vinfo.getRelease() : VersionInfo.UNAVAILABLE) + ")";
@@ -169,19 +169,19 @@ public class TestApacheHttpClient implem
             System.out.println("Usage: <target URI> <no of requests> <concurrent
connections>");
             System.exit(-1);
         }
-        URI targetURI = new URI(args[0]);
-        int n = Integer.parseInt(args[1]);
+        final URI targetURI = new URI(args[0]);
+        final int n = Integer.parseInt(args[1]);
         int c = 1;
         if (args.length > 2) {
             c = Integer.parseInt(args[2]);
         }
 
-        TestApacheHttpClient test = new TestApacheHttpClient();
+        final TestApacheHttpClient test = new TestApacheHttpClient();
         test.init();
         try {
-            long startTime = System.currentTimeMillis();
-            Stats stats = test.get(targetURI, n, c);
-            long finishTime = System.currentTimeMillis();
+            final long startTime = System.currentTimeMillis();
+            final Stats stats = test.get(targetURI, n, c);
+            final long finishTime = System.currentTimeMillis();
 
             Stats.printStats(targetURI, startTime, finishTime, stats);
         } finally {

Modified: httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/TestHttpJRE.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/TestHttpJRE.java?rev=1480206&r1=1480205&r2=1480206&view=diff
==============================================================================
--- httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/TestHttpJRE.java
(original)
+++ httpcomponents/benchmark/httpclient/trunk/src/main/java/org/apache/http/client/benchmark/TestHttpJRE.java
Wed May  8 09:45:39 2013
@@ -54,11 +54,11 @@ public class TestHttpJRE implements Test
         for (int i = 0; i < workers.length; i++) {
             workers[i] = new WorkerThread(stats, target, content);
         }
-        for (int i = 0; i < workers.length; i++) {
-            workers[i].start();
+        for (final WorkerThread worker : workers) {
+            worker.start();
         }
-        for (int i = 0; i < workers.length; i++) {
-            workers[i].join();
+        for (final WorkerThread worker : workers) {
+            worker.join();
         }
         return stats;
     }



Mime
View raw message