tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r419324 - in /tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport: SocketNioReceive.java SocketNioSend.java SocketReceive.java SocketSend.java
Date Wed, 05 Jul 2006 20:06:08 GMT
Author: fhanik
Date: Wed Jul  5 13:06:07 2006
New Revision: 419324

URL: http://svn.apache.org/viewvc?rev=419324&view=rev
Log:
Updated test packages

Modified:
    tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketNioReceive.java
    tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketNioSend.java
    tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketReceive.java
    tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketSend.java

Modified: tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketNioReceive.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketNioReceive.java?rev=419324&r1=419323&r2=419324&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketNioReceive.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketNioReceive.java
Wed Jul  5 13:06:07 2006
@@ -1,18 +1,23 @@
 package org.apache.catalina.tribes.test.transport;
 
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.io.InputStream;
 import java.text.DecimalFormat;
-import org.apache.catalina.tribes.transport.nio.NioReceiver;
-import org.apache.catalina.tribes.MessageListener;
+
 import org.apache.catalina.tribes.ChannelMessage;
-import org.apache.catalina.tribes.io.XByteBuffer;
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.MessageListener;
 import org.apache.catalina.tribes.io.ChannelData;
+import org.apache.catalina.tribes.io.XByteBuffer;
 import org.apache.catalina.tribes.membership.MemberImpl;
-import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.transport.nio.NioReceiver;
 
 public class SocketNioReceive {
+    static int count = 0;
+    static int accept = 0;
+    static long start = 0;
+    static double mb = 0;
+    static int len = 0;
+    static DecimalFormat df = new DecimalFormat("##.00");
+    static double seconds = 0;
 
     protected static Object mutex = new Object();
     public static void main(String[] args) throws Exception {
@@ -22,18 +27,21 @@
         byte[] buf = new byte[8192 * 4];
         data.setMessage(new XByteBuffer(buf, false));
         buf = XByteBuffer.createDataPackage(data);
-        int len = buf.length;
+        len = buf.length;
         NioReceiver receiver = new NioReceiver();
         receiver.setPort(9999);
         receiver.setHost("localhost");
-        MyList list = new MyList(len);
+        MyList list = new MyList();
         receiver.setMessageListener(list);
         receiver.start();
         System.out.println("Listening on 9999");
         while (true) {
             try {
                 synchronized (mutex) {
-                    mutex.wait();
+                    mutex.wait(5000);
+                    if ( start != 0 ) {
+                        System.out.println("Throughput " + df.format(mb / seconds) + " MB/seconds,
messages "+count+" accepts "+accept);
+                    }
                 }
             }catch (Throwable x) {
                 x.printStackTrace();
@@ -42,29 +50,25 @@
     }
     
     public static class MyList implements MessageListener {
-        public MyList(int len) {
-            this.len = len;
-        }
         boolean first = true;
-        int count = 0;
-        DecimalFormat df = new DecimalFormat("##.00");
-        long start = 0;
-        double mb;
-        int len;
+        
+        
         public void messageReceived(ChannelMessage msg) {
             if (first) {
                 first = false;
                 start = System.currentTimeMillis();
             }
             mb += ( (double) len) / 1024 / 1024;
-            if ( ( (count++) % 10000) == 0) {
+            synchronized (this) {count++;}
+            if ( ( (count) % 10000) == 0) {
                 long time = System.currentTimeMillis();
-                double seconds = ( (double) (time - start)) / 1000;
-                System.out.println("Throughput " + df.format(mb / seconds) + " MB/seconds");
+                seconds = ( (double) (time - start)) / 1000;
+                System.out.println("Throughput " + df.format(mb / seconds) + " MB/seconds,
messages "+count);
             }
         }        
 
         public boolean accept(ChannelMessage msg) {
+            synchronized (this) {accept++;}
             return true;
         }
 

Modified: tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketNioSend.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketNioSend.java?rev=419324&r1=419323&r2=419324&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketNioSend.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketNioSend.java
Wed Jul  5 13:06:07 2006
@@ -37,7 +37,7 @@
         boolean first = true;
         int count = 0;
         DecimalFormat df = new DecimalFormat("##.00");
-        while (true) {
+        while (count<100000) {
             if (first) {
                 first = false;
                 start = System.currentTimeMillis();
@@ -66,7 +66,7 @@
                         sender.reset();
                         sender.setMessage(buf);
                         mb += ( (double) len) / 1024 / 1024;
-                        if ( ( (count++) % 10000) == 0) {
+                        if ( ( (++count) % 10000) == 0) {
                             long time = System.currentTimeMillis();
                             double seconds = ( (double) (time - start)) / 1000;
                             System.out.println("Throughput " + df.format(mb / seconds) +
" MB/seconds");

Modified: tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketReceive.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketReceive.java?rev=419324&r1=419323&r2=419324&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketReceive.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketReceive.java
Wed Jul  5 13:06:07 2006
@@ -24,7 +24,7 @@
             int len = in.read(buf);
             if ( len == -1 ) System.exit(1);
             mb += ( (double) len) / 1024 / 1024;
-            if ( ((count++) % 10000) == 0 ) {
+            if ( ((++count) % 10000) == 0 ) {
                 long time = System.currentTimeMillis();
                 double seconds = ((double)(time-start))/1000;
                 System.out.println("Throughput "+df.format(mb/seconds)+" MB/seconds");

Modified: tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketSend.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketSend.java?rev=419324&r1=419323&r2=419324&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketSend.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/transport/SocketSend.java
Wed Jul  5 13:06:07 2006
@@ -29,14 +29,14 @@
         boolean first = true;
         int count = 0;
         DecimalFormat df = new DecimalFormat("##.00");
-        while ( true ) {
+        while ( count<100000 ) {
             if ( first ) { first = false; start = System.currentTimeMillis();}
             out.write(buf);
             mb += ( (double) buf.length) / 1024 / 1024;
-            if ( ((count++) % 10000) == 0 ) {
+            if ( ((++count) % 10000) == 0 ) {
                 long time = System.currentTimeMillis();
                 double seconds = ((double)(time-start))/1000;
-                System.out.println("Throughput "+df.format(mb/seconds)+" MB/seconds");
+                System.out.println("Throughput "+df.format(mb/seconds)+" MB/seconds messages
"+count);
             }
         }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message