jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1220590 - in /jmeter/trunk: src/components/org/apache/jmeter/visualizers/TableVisualizer.java src/core/org/apache/jmeter/visualizers/TableSample.java xdocs/changes.xml
Date Mon, 19 Dec 2011 02:03:15 GMT
Author: sebb
Date: Mon Dec 19 02:03:15 2011
New Revision: 1220590

URL: http://svn.apache.org/viewvc?rev=1220590&view=rev
Log:
Bug 52357 - View results in Table does not allow for multiple result samples
Complete

Added:
    jmeter/trunk/src/core/org/apache/jmeter/visualizers/TableSample.java   (with props)
Modified:
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/TableVisualizer.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/TableVisualizer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/TableVisualizer.java?rev=1220590&r1=1220589&r2=1220590&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/TableVisualizer.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/TableVisualizer.java Mon Dec
19 02:03:15 2011
@@ -107,7 +107,7 @@ public class TableVisualizer extends Abs
     // Column renderers
     private static final TableCellRenderer[] RENDERERS =
         new TableCellRenderer[]{
-            null, // Count
+            new RightAlignRenderer(), // Sample number (string)
             new RightAlignRenderer(), // Start Time
             null, // Thread Name
             null, // Label
@@ -122,19 +122,19 @@ public class TableVisualizer extends Abs
     public TableVisualizer() {
         super();
         model = new ObjectTableModel(COLUMNS,
-                Sample.class,         // The object used for each row
+                TableSample.class,         // The object used for each row
                 new Functor[] {
-                new Functor("getCount"), // $NON-NLS-1$
+                new Functor("getSampleNumberString"), // $NON-NLS-1$
                 new Functor("getStartTimeFormatted",  // $NON-NLS-1$
                         new Object[]{format}),
                 new Functor("getThreadName"), // $NON-NLS-1$
                 new Functor("getLabel"), // $NON-NLS-1$
-                new Functor("getData"), // $NON-NLS-1$
+                new Functor("getElapsed"), // $NON-NLS-1$
                 new SampleSuccessFunctor("isSuccess"), // $NON-NLS-1$
                 new Functor("getBytes") }, // $NON-NLS-1$
                 new Functor[] { null, null, null, null, null, null, null },
                 new Class[] {
-                Long.class, String.class, String.class, String.class, Long.class, ImageIcon.class,
Integer.class });
+                String.class, String.class, String.class, String.class, Long.class, ImageIcon.class,
Integer.class });
         init();
     }
 
@@ -150,7 +150,7 @@ public class TableVisualizer extends Abs
 
     protected synchronized void updateTextFields(SampleResult res) {
         noSamplesField.setText(Long.toString(calc.getCount()));
-        dataField.setText(Long.toString(res.getTime()));
+        dataField.setText(Long.toString(res.getTime()/res.getSampleCount()));
         averageField.setText(Long.toString((long) calc.getMean()));
         deviationField.setText(Long.toString((long) calc.getStandardDeviation()));
     }
@@ -168,9 +168,15 @@ public class TableVisualizer extends Abs
         synchronized (calc) {
             calc.addSample(res);
             int count = calc.getCount();
-            Sample newS = new Sample(res.getSampleLabel(), res.getTime(), 0, 0, 0, 0, 0,
0,
-                    res.isSuccessful(), count, res.getEndTime(),res.getBytes(),
-                    res.getThreadName());
+            TableSample newS = new TableSample(
+                    count, 
+                    res.getSampleCount(), 
+                    res.getStartTime(), 
+                    res.getThreadName(), 
+                    res.getSampleLabel(),
+                    res.getTime(),
+                    res.isSuccessful(),
+                    res.getBytes());
             model.addRow(newS);
         }
         updateTextFields(res);

Added: jmeter/trunk/src/core/org/apache/jmeter/visualizers/TableSample.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/visualizers/TableSample.java?rev=1220590&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/visualizers/TableSample.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/visualizers/TableSample.java Mon Dec 19 02:03:15
2011
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.visualizers;
+
+import java.io.Serializable;
+import java.text.Format;
+import java.util.Date;
+
+/**
+ * Class to hold data for the TableVisualiser.
+ */
+public class TableSample implements Serializable, Comparable<TableSample> {
+    private static final long serialVersionUID = 240L;
+
+    private final long totalSamples;
+    
+    private final int sampleCount; // number of samples in this entry
+
+    private final long startTime;
+
+    private final String threadName;
+    
+    private final String label;
+
+    private final long elapsed;
+
+    private final boolean success;
+
+    private final long bytes;
+
+    public TableSample(long totalSamples, int sampleCount, long startTime, String threadName,
+            String label,
+            long elapsed, boolean success, long bytes) {
+        this.totalSamples = totalSamples;
+        this.sampleCount = sampleCount;
+        this.startTime = startTime;
+        this.threadName = threadName;
+        this.label = label;
+        this.elapsed = elapsed/sampleCount;
+        this.success = success;
+        this.bytes = bytes/sampleCount;
+    }
+
+    // The following getters may appear not to be used - however they are invoked via the
Functor class
+
+    public long getBytes() {
+        return bytes;
+    }
+
+    public String getSampleNumberString(){
+        StringBuilder sb = new StringBuilder();
+        if (sampleCount > 1) {
+        sb.append(totalSamples-sampleCount+1);
+        sb.append('-');
+        }
+        sb.append(totalSamples);
+        return sb.toString();
+    }
+
+    public long getElapsed() {
+        return elapsed;
+    }
+
+    public boolean isSuccess() {
+        return success;
+    }
+
+    public long getStartTime() {
+        return startTime;
+    }
+
+    /**
+     * @return the start time using the specified format
+     * Intended for use from Functors
+     */
+    public String getStartTimeFormatted(Format format) {
+        return format.format(new Date(getStartTime()));
+    }
+
+    public String getThreadName() {
+        return threadName;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public int compareTo(TableSample o) {
+        TableSample oo = o;
+        return ((totalSamples - oo.totalSamples) < 0 ? -1 : (totalSamples == oo.totalSamples
? 0 : 1));
+    }
+
+    // TODO should equals and hashCode depend on field other than count?
+    
+    @Override
+    public boolean equals(Object o){
+        return (
+                (o instanceof TableSample) &&
+                (this.compareTo((TableSample) o) == 0)
+                );
+    }
+
+    @Override
+    public int hashCode(){
+        return (int)(totalSamples ^ (totalSamples >>> 32));
+    }
+
+}

Propchange: jmeter/trunk/src/core/org/apache/jmeter/visualizers/TableSample.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jmeter/trunk/src/core/org/apache/jmeter/visualizers/TableSample.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1220590&r1=1220589&r2=1220590&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Mon Dec 19 02:03:15 2011
@@ -120,6 +120,7 @@ This behaviour can be changed with prope
 
 <h3>Listeners</h3>
 <ul>
+<li>Bug 52357 - View results in Table does not allow for multiple result samples</li>
 </ul>
 
 <h3>Assertions</h3>



Mime
View raw message