qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arnaudsi...@apache.org
Subject svn commit: r599403 - /incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/client/perf/MessageProducerTest.java
Date Thu, 29 Nov 2007 12:12:09 GMT
Author: arnaudsimon
Date: Thu Nov 29 04:12:08 2007
New Revision: 599403

URL: http://svn.apache.org/viewvc?rev=599403&view=rev
Log:
added interval thoughput calculation

Modified:
    incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/client/perf/MessageProducerTest.java

Modified: incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/client/perf/MessageProducerTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/client/perf/MessageProducerTest.java?rev=599403&r1=599402&r2=599403&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/client/perf/MessageProducerTest.java
(original)
+++ incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/client/perf/MessageProducerTest.java
Thu Nov 29 04:12:08 2007
@@ -24,7 +24,8 @@
     private int _count;
     String _logFileName;
     long _startTime;
-    long totalMsgCount;
+    long _totalMsgCount;
+    double _timeElapsed = 0;
 
     public void start() throws Exception
     {
@@ -98,6 +99,8 @@
         try
         {
             FileWriter _logFile = new FileWriter(_logFileName + ".csv",true);
+            long newTotalMsgCount = 0;
+            long totalMsgCountThisInterval = 0;
             for (Integer id : _producers.keySet())
             {
                 JMSProducer prod = _producers.get(id);
@@ -107,23 +110,29 @@
                 buf.append(d.getTime()).append(",");
                 buf.append(prod.getCurrentMessageCount()).append("\n");
                 _logFile.write(buf.toString());
-                totalMsgCount = totalMsgCount + prod.getCurrentMessageCount();
+                newTotalMsgCount = newTotalMsgCount + prod.getCurrentMessageCount();
+                totalMsgCountThisInterval = newTotalMsgCount - _totalMsgCount;
+                _totalMsgCount = newTotalMsgCount;
             }
             _logFile.close();
 
             FileWriter _memoryLog = new FileWriter(_logFileName + "_memory.csv",true);
             StringBuffer buf = new StringBuffer("JMSProducer,");
             Date d = new Date(System.currentTimeMillis());
+            double totaltime = d.getTime() - _startTime;
+            _timeElapsed = totaltime - _timeElapsed;
             buf.append(df.format(d)).append(",");
             buf.append(d.getTime()).append(",");
-            buf.append(totalMsgCount).append(",");
+            buf.append(_totalMsgCount).append(",");
             buf.append(Runtime.getRuntime().totalMemory() -Runtime.getRuntime().freeMemory()).append("\n");
+            buf.append("\n");
+            buf.append("Throughput: total " + (_totalMsgCount /totaltime)*1000 + " msg/s;
 this interval: "  +  (totalMsgCountThisInterval/_timeElapsed)*1000 + " msg/s");
             _memoryLog.write(buf.toString());
             _memoryLog.close();
+            System.out.println(buf);
             if (printSummary)
             {
-                double totaltime = d.getTime() - _startTime;
-                double dCount = totalMsgCount;
+                double dCount = _totalMsgCount;
                 double ratio = (dCount/totaltime)*1000;
                 FileWriter _summaryLog = new FileWriter(_logFileName + "_Summary",true);
                 buf = new StringBuffer("MessageProducerTest \n Test started at : ");
@@ -131,12 +140,13 @@
                 d = new Date(System.currentTimeMillis());
                 buf.append(df.format(d)).append("\n Total Time taken (ms):");
                 buf.append(totaltime).append("\n Total messages sent:");
-                buf.append(totalMsgCount).append("\n Producer rate:");
+                buf.append(_totalMsgCount).append("\n Producer rate:");
                 buf.append(ratio).append("\n");
                 _summaryLog.write(buf.toString());
                 System.out.println("---------- Test Ended -------------");
                 _summaryLog.close();
             }
+            _timeElapsed = totaltime;
         }
         catch(Exception e)
         {



Mime
View raw message