The Aggregate Report visualizer will not immediately display results 
read from a file, since it only allows one update a second and typically 
the results are read from the file in less than this time. This is not a 
problem if new live samples come in, but it does prevent the Aggregate 
Report being used to view data collected  by other visualizers, after 
sampling has stopped.

Also, when reading existing samples from a file, incorrect rates can be 
displayed, since the first and last sample times are obtained using 
System.currentTimeMillis(), rather than the timestamp on the SampleResult.

I attach a simple patch to fix this problem.

//derek


________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
Index: src_1/org/apache/jmeter/visualizers/RunningSample.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-jmeter/src_1/org/apache/jmeter/visualizers/RunningSample.java,v
retrieving revision 1.4
diff -u -r1.4 RunningSample.java
--- src_1/org/apache/jmeter/visualizers/RunningSample.java      1 May 2002 23:48:53 
-0000       1.4
+++ src_1/org/apache/jmeter/visualizers/RunningSample.java      16 Jul 2002 08:18:32 
+-0000
@@ -57,6 +57,8 @@
 // java
 import java.text.DecimalFormat;
 
+import org.apache.jmeter.samplers.SampleResult;
+
 
 /**
  * Title:        RunningSample.java
@@ -78,6 +80,7 @@
     private long max, min;
     private long errorCount;
     private long firstTime;
+    private long lastTime;
 
     /**
      * use this constructor.
@@ -89,6 +92,7 @@
         min = Long.MAX_VALUE;
         errorCount = 0L;
         firstTime = 0L;
+        lastTime = 0L;
     }
 
     /**
@@ -101,7 +105,7 @@
      * @return a String representation of the rate the samples are being taken at.
      */
     public String getRateString() {
-        long howLongRunning = System.currentTimeMillis() - firstTime;
+        long howLongRunning = lastTime - firstTime;
 
         if (howLongRunning == 0) return ("N/A");
         double samplesPerSecond = ((double) counter / ((double) howLongRunning / 
1000.0));
@@ -130,11 +134,15 @@
      * @arg aTimeInMillis Time in milliseconds that this sample took to process
      * @arg aSuccessFlag Flag for if this sample was successful or not
      */
-    public synchronized void addSample(long aTimeInMillis, boolean aSuccessFlag) {
+    public synchronized void addSample(SampleResult res) {
+               long aTimeInMillis = res.getTime();
+               boolean aSuccessFlag = res.isSuccessful();
+               lastTime = res.getTimeStamp();
+
         counter++;
         if (firstTime == 0L) {
-            // this is our first sample, set the start time to current system time..
-            firstTime = System.currentTimeMillis();
+            // this is our first sample, set the start time to current timestamp
+            firstTime = lastTime;
         }
         runningSum += aTimeInMillis;
         if (aTimeInMillis > max) max = aTimeInMillis;
Index: src_1/org/apache/jmeter/visualizers/StatVisualizer.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-jmeter/src_1/org/apache/jmeter/visualizers/StatVisualizer.java,v
retrieving revision 1.8
diff -u -r1.8 StatVisualizer.java
--- src_1/org/apache/jmeter/visualizers/StatVisualizer.java     13 Jun 2002 00:45:18 
-0000      1.8
+++ src_1/org/apache/jmeter/visualizers/StatVisualizer.java     16 Jul 2002 08:18:33 
+-0000
@@ -71,6 +71,7 @@
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jmeter.visualizers.gui.AbstractVisualizer;
 import org.apache.jmeter.samplers.Clearable;
+import org.apache.jmeter.testelement.TestElement;
 
 
 /****************************************
@@ -87,7 +88,6 @@
 
 public class StatVisualizer extends AbstractVisualizer implements Scrollable, 
GraphListener,Clearable
 {
-
 //    protected NamePanel namePanel;
 
 //    protected GraphAccum graph;
@@ -254,6 +254,16 @@
        public void updateGui(Sample s)
        {
                updateGui();
+       }
+
+       // overrides AbstractVisualizer
+       // forces GUI update after sample file has been read
+       public TestElement createTestElement()
+       {
+               TestElement t = super.createTestElement();
+               sleepTill = 0;
+               updateGui();
+               return t;
        }
 
        /****************************************
Index: src_1/org/apache/jmeter/visualizers/StatVisualizerModel.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-jmeter/src_1/org/apache/jmeter/visualizers/StatVisualizerModel.java,v
retrieving revision 1.7
diff -u -r1.7 StatVisualizerModel.java
--- src_1/org/apache/jmeter/visualizers/StatVisualizerModel.java        18 Jun 2002 
01:01:14 -0000      1.7
+++ src_1/org/apache/jmeter/visualizers/StatVisualizerModel.java        16 Jul 2002 
+08:18:34 -0000
@@ -180,9 +180,33 @@
         ***************************************/
        public void addNewSample(SampleResult res)
        {
-               boolean wasSuccessful = res.isSuccessful();
-               addNewSample(res.getTime(), (String)res.getSampleLabel(), 
wasSuccessful,
-                               (String)res.getResponseCode());
+               String aLabel = res.getSampleLabel();
+               String responseCode = res.getResponseCode();
+               RunningSample myRS;
+
+               if (responseCodeMap.containsKey(responseCode))
+               {
+                       long tempLong =
+                               ((Long)responseCodeMap.get(responseCode)).longValue();
+                       responseCodeMap.put(responseCode, new Long(++tempLong));
+               }
+               else
+               {
+                       responseCodeMap.put(responseCode, new Long(1));
+               }
+
+               if (labelMap.containsKey(aLabel))
+               {
+                       myRS = (RunningSample)labelMap.get(aLabel);
+               }
+               else
+               {
+                       // put a new one there..
+                       myRS = new RunningSample();
+                       labelMap.put(aLabel, myRS);
+               }
+
+               myRS.addSample(res);
                this.fireDataChanged();
        }
 
@@ -216,59 +240,6 @@
                        ((GraphListener)myObj).updateGui();
                }
        }
-
-       /****************************************
-        * Adds a feature to the NewSample attribute of the StatVisualizerModel object
-        *
-        *@param sample        The feature to be added to the NewSample attribute
-        *@param aLabel        The feature to be added to the NewSample attribute
-        *@param isSuccess     The feature to be added to the NewSample attribute
-        *@param responseCode  The feature to be added to the NewSample attribute
-        ***************************************/
-       private void addNewSample(long sample, String aLabel, boolean isSuccess, 
String responseCode)
-       {
-
-               if(responseCodeMap.containsKey(responseCode))
-               {
-
-                       long tempLong = 
((Long)responseCodeMap.get(responseCode)).longValue();
-
-                       tempLong++;
-
-                       responseCodeMap.put(responseCode, new Long(tempLong));
-
-               }
-               else
-               {
-
-                       responseCodeMap.put(responseCode, new Long(1));
-
-               }
-
-               RunningSample myRS;
-
-               if(labelMap.containsKey(aLabel))
-               {
-
-                       myRS = (RunningSample)labelMap.get(aLabel);
-
-               }
-               else
-               {
-
-                       // put a new one there..
-
-                       myRS = new RunningSample();
-
-                       labelMap.put(aLabel, myRS);
-
-               }
-
-               myRS.addSample(sample, isSuccess);
-
-
-       }
-
 
 }
 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to