tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r381651 - /tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/LoadTest.java
Date Tue, 28 Feb 2006 13:17:48 GMT
Author: fhanik
Date: Tue Feb 28 05:17:46 2006
New Revision: 381651

URL: http://svn.apache.org/viewcvs?rev=381651&view=rev
Log:
Fixed measurement, not super accurate, but it gives a hint

Modified:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/LoadTest.java

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/LoadTest.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/LoadTest.java?rev=381651&r1=381650&r2=381651&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/LoadTest.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/LoadTest.java
Tue Feb 28 05:17:46 2006
@@ -51,14 +51,39 @@
     static int messageSize = 0;
     
     public static long messagesSent = 0;
-    public static long messageSendTime = 0;
+    public static long messageStartSendTime = 0;
+    public static long messageEndSendTime = 0;
+    public static int  threadCount = 0;
+    
+    public static synchronized void startTest() {
+        threadCount++;
+        if ( messageStartSendTime == 0 ) messageStartSendTime = System.currentTimeMillis();
+    }
+    
+    public static synchronized void endTest() {
+        threadCount--;
+        if ( messageEndSendTime == 0 && threadCount==0 ) messageEndSendTime = System.currentTimeMillis();
+    }
+
     
-    public static synchronized long addSendStats(long count, long time) {
+    public static synchronized long addSendStats(long count) {
         messagesSent+=count;
-        messageSendTime+=time;
         return 0l;
     }    
     
+    private static void printSendStats(long counter, int messageSize) {
+        float cnt = (float)counter;
+        float size = (float)messageSize;
+        float time = (float)(System.currentTimeMillis()-messageStartSendTime) / 1000f;
+        log.info("****SEND STATS-"+Thread.currentThread().getName()+"*****"+
+                 "\n\tMessage count:"+counter+
+                 "\n\tTotal bytes  :"+(long)(size*cnt)+
+                 "\n\tTotal seconds:"+(time)+
+                 "\n\tBytes/second :"+(size*cnt/time)+
+                 "\n\tMBytes/second:"+(size*cnt/time/1024f/1024f));
+    }
+
+    
     
     public LoadTest(ManagedChannel channel, 
                     boolean send,
@@ -83,8 +108,9 @@
         long counter = 0;
         LoadMessage msg = new LoadMessage();
         int messageSize = LoadTest.messageSize;
-        long sendTime = 0;
+        
         try {
+            startTest();
             while (counter < msgCount) {
                 if (channel.getMembers().length == 0 || (!send)) {
                     synchronized (mutex) {
@@ -97,12 +123,10 @@
                 } else {
                     try {
                         msg.setMsgNr((int)++counter);
-                        long start = System.currentTimeMillis();
                         if (debug) {
                             printArray(msg.getMessage());
                         }
                         channel.send(null, msg);
-                        sendTime += (System.currentTimeMillis() - start);
                         if ( pause > 0 ) {
                             if ( debug) System.out.println("Pausing sender for "+pause+"
ms.");
                             Thread.sleep(pause);
@@ -117,31 +141,22 @@
                 }
                 if ( (counter % statsInterval) == 0 && (counter > 0)) {
                     //add to the global counter
-                    //counter = sendTime = addSendStats(counter,sendTime);
+                    counter = addSendStats(counter);
                     //print from the global counter
                     //printSendStats(LoadTest.messagesSent, LoadTest.messageSize, LoadTest.messageSendTime);
-                    printSendStats(counter, LoadTest.messageSize, sendTime);
+                    printSendStats(LoadTest.messagesSent, LoadTest.messageSize);
                     
                 }
 
             }
         }catch ( Exception x ) {
             x.printStackTrace();
-            printSendStats(counter, messageSize, sendTime);
+            printSendStats(LoadTest.messagesSent, LoadTest.messageSize);
         }
+        endTest();
     }
 
-    private void printSendStats(long counter, int messageSize, long sendTime) {
-        float cnt = (float)counter;
-        float size = (float)messageSize;
-        float time = (float)sendTime / 1000;
-        log.info("****SEND STATS-"+Thread.currentThread().getName()+"*****"+
-                 "\n\tMessage count:"+counter+
-                 "\n\tTotal bytes  :"+(long)(size*cnt)+
-                 "\n\tTotal seconds:"+(time)+
-                 "\n\tBytes/second :"+(size*cnt/time)+
-                 "\n\tMBytes/second:"+(size*cnt/time/1024f/1024f));
-    }
+    
 
     /**
      * memberAdded
@@ -169,7 +184,7 @@
     }
     
     public boolean accept(Serializable msg, Member mbr){ 
-       return (msg instanceof LoadMessage);
+       return (msg instanceof LoadMessage) || (msg instanceof ByteMessage);
     }
     
     public void messageReceived(Serializable msg, Member mbr){ 
@@ -180,12 +195,13 @@
             }
         }
         
-        if ( msg instanceof ByteMessage ) {
+        if ( msg instanceof ByteMessage && !(msg instanceof LoadMessage)) {
             LoadMessage tmp = new LoadMessage();
             tmp.setMessage(((ByteMessage)msg).getMessage());
             msg = tmp;
             tmp = null;
         }
+        
         
         bytesReceived+=((LoadMessage)msg).getMessage().length;
         messagesReceived++;



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


Mime
View raw message