jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1783270 - /jmeter/trunk/src/components/org/apache/jmeter/visualizers/SummaryReport.java
Date Thu, 16 Feb 2017 18:41:11 GMT
Author: fschumacher
Date: Thu Feb 16 18:41:11 2017
New Revision: 1783270

URL: http://svn.apache.org/viewvc?rev=1783270&view=rev
Log:
Keep GUI responsive when many events are processed by View Results Tree, Summary Report and
Log Panel.
Modify the model only, when we are in the AWT thread. Use more features of ConcurrentHashMap.

Bugzilla Id: 60687


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

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/SummaryReport.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SummaryReport.java?rev=1783270&r1=1783269&r2=1783270&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/SummaryReport.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/SummaryReport.java Thu Feb 16
18:41:11 2017
@@ -28,8 +28,10 @@ import java.io.OutputStreamWriter;
 import java.nio.charset.Charset;
 import java.text.DecimalFormat;
 import java.text.Format;
+import java.util.Deque;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedDeque;
 
 import javax.swing.BoxLayout;
 import javax.swing.JButton;
@@ -112,6 +114,8 @@ public class SummaryReport extends Abstr
 
     private final Map<String, Calculator> tableRows = new ConcurrentHashMap<>();
 
+    private final Deque<Calculator> newRows = new ConcurrentLinkedDeque<>();
+
     // Column renderers
     private static final TableCellRenderer[] RENDERERS =
         new TableCellRenderer[]{
@@ -172,6 +176,9 @@ public class SummaryReport extends Abstr
             }
             dataChanged = false;
             synchronized (lock) {
+                while (!newRows.isEmpty()) {
+                    model.insertRow(newRows.pop(), model.getRowCount() - 1);
+                }
                 model.fireTableDataChanged();
             }
         }).start();
@@ -194,16 +201,11 @@ public class SummaryReport extends Abstr
 
     @Override
     public void add(final SampleResult res) {
-        final String sampleLabel = res.getSampleLabel(useGroupName.isSelected());
-        Calculator row;
-        synchronized (lock) {
-            row = tableRows.get(sampleLabel);
-            if (row == null) {
-                row = new Calculator(sampleLabel);
-                tableRows.put(row.getLabel(), row);
-                model.insertRow(row, model.getRowCount() - 1);
-            }
-        }
+        Calculator row = tableRows.computeIfAbsent(res.getSampleLabel(useGroupName.isSelected()),
label -> {
+            Calculator newRow = new Calculator(label);
+            newRows.add(newRow);
+            return newRow;
+        });
         /*
          * Synch is needed because multiple threads can update the counts.
          */
@@ -211,7 +213,7 @@ public class SummaryReport extends Abstr
             row.addSample(res);
         }
         Calculator tot = tableRows.get(TOTAL_ROW_LABEL);
-        synchronized (tot) {
+        synchronized (lock) {
             tot.addSample(res);
         }
         dataChanged = true;
@@ -225,6 +227,7 @@ public class SummaryReport extends Abstr
         //Synch is needed because a clear can occur while add occurs
         synchronized (lock) {
             model.clearData();
+            newRows.clear();
             tableRows.clear();
             tableRows.put(TOTAL_ROW_LABEL, new Calculator(TOTAL_ROW_LABEL));
             model.addRow(tableRows.get(TOTAL_ROW_LABEL));



Mime
View raw message