jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1783556 - /jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java
Date Sat, 18 Feb 2017 14:06:36 GMT
Author: fschumacher
Date: Sat Feb 18 14:06:36 2017
New Revision: 1783556

URL: http://svn.apache.org/viewvc?rev=1783556&view=rev
Log:
Make GUI more responsive when it gets a lot of events.
Convert Aggregate Graph to use a queue, when new rows are to be inserted.
Update the model (or at least notify the gui) only periodically.
That way we get the update of the model out of the busy path of the swing
event loop.

Bugzilla Id: 60687

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java?rev=1783556&r1=1783555&r2=1783556&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java Sat
Feb 18 14:06:36 2017
@@ -33,9 +33,11 @@ import java.text.DecimalFormat;
 import java.text.Format;
 import java.text.MessageFormat;
 import java.util.ArrayList;
+import java.util.Deque;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedDeque;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
@@ -58,6 +60,7 @@ import javax.swing.JTabbedPane;
 import javax.swing.JTable;
 import javax.swing.JTextField;
 import javax.swing.SwingConstants;
+import javax.swing.Timer;
 import javax.swing.UIManager;
 import javax.swing.border.Border;
 import javax.swing.border.EmptyBorder;
@@ -254,6 +257,8 @@ public class StatGraphVisualizer extends
 
     private Pattern pattern = null;
 
+    private Deque<SamplingStatCalculator> newRows = new ConcurrentLinkedDeque<>();
+
     public StatGraphVisualizer() {
         super();
         model = createObjectTableModel();
@@ -422,20 +427,17 @@ public class StatGraphVisualizer extends
             matcher = pattern.matcher(sampleLabel);
         }
         if ((matcher == null) || (matcher.find())) {
-            JMeterUtils.runSafe(false, () -> {
-                    SamplingStatCalculator row = null;
-                    synchronized (lock) {
-                        row = tableRows.get(sampleLabel);
-                        if (row == null) {
-                            row = new SamplingStatCalculator(sampleLabel);
-                            tableRows.put(row.getLabel(), row);
-                            model.insertRow(row, model.getRowCount() - 1);
-                        }
-                    }
-                    row.addSample(res);
-                    tableRows.get(TOTAL_ROW_LABEL).addSample(res);
-                    model.fireTableDataChanged();
+            SamplingStatCalculator row = tableRows.computeIfAbsent(sampleLabel, label ->
{
+                SamplingStatCalculator newRow = new SamplingStatCalculator(label);
+                newRows.addLast(newRow);
+                return newRow;
             });
+            synchronized (row) {
+                row.addSample(res);
+            }
+            synchronized (lock) {
+                tableRows.get(TOTAL_ROW_LABEL).addSample(res);
+            }
         }
     }
 
@@ -514,6 +516,14 @@ public class StatGraphVisualizer extends
 
         this.add(mainPanel, BorderLayout.NORTH);
         this.add(spane, BorderLayout.CENTER);
+        new Timer(500, e -> {
+                synchronized (lock) {
+                    while (!newRows.isEmpty()) {
+                        model.insertRow(newRows.pop(), model.getRowCount() - 1);
+                    }
+                }
+                model.fireTableDataChanged();
+        }).start();
     }
 
     public void makeGraph() {



Mime
View raw message