You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2013/06/06 10:49:47 UTC

git commit: Added some logs

Updated Branches:
  refs/heads/trunk f5f64750c -> 0d07aadd6


Added some logs

Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/0d07aadd
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/0d07aadd
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/0d07aadd

Branch: refs/heads/trunk
Commit: 0d07aadd67029ebd97cec72bb9658b521a476339
Parents: f5f6475
Author: Emmanuel Lécharny <el...@apache.org>
Authored: Thu Jun 6 10:48:02 2013 +0200
Committer: Emmanuel Lécharny <el...@apache.org>
Committed: Thu Jun 6 10:48:02 2013 +0200

----------------------------------------------------------------------
 .../org/apache/mina/core/BenchmarkBinaryTest.java  |   43 ++++++++++++---
 1 files changed, 35 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/0d07aadd/benchmarks/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java b/benchmarks/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
index 2865a75..b55f367 100755
--- a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
+++ b/benchmarks/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
@@ -38,6 +38,7 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
 /**
+ * Binary benchmark
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
 @RunWith(Parameterized.class)
@@ -66,13 +67,10 @@ public abstract class BenchmarkBinaryTest {
 
     public abstract Type getServerType();
 
-    @Parameters(name="{0} messages of size {1}")
+    @Parameters(name = "{0} messages of size {1}")
     public static Collection<Object[]> getParameters() {
-        Object[][] parameters = new Object[][] { 
-                { 100000, 10, 2 * 60 }, 
-                { 100000, 1 * 1024, 2 * 60 },
-                { 100000, 10 * 1024, 2 * 60 }, 
-                { 100, 64 * 1024 * 1024, 10 * 60 } };
+        Object[][] parameters = new Object[][] { { 100000, 10, 2 * 60 }, { 100000, 1 * 1024, 2 * 60 },
+                { 100000, 10 * 1024, 2 * 60 }, { 100, 64 * 1024 * 1024, 10 * 60 } };
         return Arrays.asList(parameters);
     }
 
@@ -119,9 +117,38 @@ public abstract class BenchmarkBinaryTest {
     @Test
     public void benchmark() throws IOException, InterruptedException {
         CountDownLatch counter = new CountDownLatch(numberOfMessages);
+        CounterFilter.messageSent.set(0);
 
+        boolean result = false;
+
+        System.out.println("-------------- Sending " + data.length + " bytes");
         client.start(port, counter, data);
-        boolean result = counter.await(timeout, TimeUnit.SECONDS);
-        assertTrue("Still " + counter.getCount() + " messages to send on a total of " + numberOfMessages, result);
+        long globalSent = 0;
+        long warmedUpSent = 0;
+        int nbSeconds = 0;
+
+        while ((counter.getCount() > 0) && (nbSeconds < 120)) {
+            result = counter.await(1, TimeUnit.SECONDS);
+
+            long nbSent = CounterFilter.messageSent.getAndSet(0);
+            nbSeconds++;
+
+            globalSent += nbSent;
+
+            if (nbSeconds > 5) {
+                warmedUpSent += nbSent;
+            }
+
+            System.out.println("Nb messages sent per second : " + nbSent);
+        }
+
+        if (nbSeconds < 120) {
+            System.out.println("Average : " + (warmedUpSent / (nbSeconds - 5)) + ", for " + globalSent
+                    + " messages sent in " + nbSeconds + "s");
+        } else {
+            System.out.println("Wasn't able to send all the messages : sent " + globalSent);
+        }
+
+        assertTrue("Still " + counter.getCount() + " messages to send of a total of " + numberOfMessages, result);
     }
 }