jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1782228 - /jmeter/trunk/src/components/org/apache/jmeter/visualizers/SummaryReport.java
Date Wed, 08 Feb 2017 18:49:05 GMT
Author: fschumacher
Date: Wed Feb  8 18:49:05 2017
New Revision: 1782228

URL: http://svn.apache.org/viewvc?rev=1782228&view=rev
Log:
Keep GUI responsive when many events are processed by View Results Tree, Summary Report and
Log Panel.
This is part two of three with the changes to Summary Report.

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=1782228&r1=1782227&r2=1782228&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/SummaryReport.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/SummaryReport.java Wed Feb 
8 18:49:05 2017
@@ -38,6 +38,7 @@ import javax.swing.JFileChooser;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTable;
+import javax.swing.Timer;
 import javax.swing.border.Border;
 import javax.swing.border.EmptyBorder;
 import javax.swing.table.TableCellRenderer;
@@ -107,6 +108,8 @@ public class SummaryReport extends Abstr
      */
     private final transient Object lock = new Object();
 
+    private volatile boolean dataChanged;
+
     private final Map<String, Calculator> tableRows = new ConcurrentHashMap<>();
 
     // Column renderers
@@ -163,6 +166,15 @@ public class SummaryReport extends Abstr
                         Double.class, Double.class, Double.class, Double.class, Double.class,
Double.class });
         clearData();
         init();
+        new Timer(200, e -> {
+            if (!dataChanged) {
+                return;
+            }
+            dataChanged = false;
+            synchronized (lock) {
+                model.fireTableDataChanged();
+            }
+        }).start();
     }
 
     /**
@@ -183,31 +195,26 @@ public class SummaryReport extends Abstr
     @Override
     public void add(final SampleResult res) {
         final String sampleLabel = res.getSampleLabel(useGroupName.isSelected());
-        JMeterUtils.runSafe(false, new Runnable() {
-            @Override
-            public void run() {
-                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);
-                    }
-                }
-                /*
-                 * Synch is needed because multiple threads can update the counts.
-                 */
-                synchronized(row) {
-                    row.addSample(res);
-                }
-                Calculator tot = tableRows.get(TOTAL_ROW_LABEL);
-                synchronized(tot) {
-                    tot.addSample(res);
-                }
-                model.fireTableDataChanged();                
+        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);
             }
-        });
+        }
+        /*
+         * Synch is needed because multiple threads can update the counts.
+         */
+        synchronized (row) {
+            row.addSample(res);
+        }
+        Calculator tot = tableRows.get(TOTAL_ROW_LABEL);
+        synchronized (tot) {
+            tot.addSample(res);
+        }
+        dataChanged = true;
     }
 
     /**
@@ -222,6 +229,7 @@ public class SummaryReport extends Abstr
             tableRows.put(TOTAL_ROW_LABEL, new Calculator(TOTAL_ROW_LABEL));
             model.addRow(tableRows.get(TOTAL_ROW_LABEL));
         }
+        dataChanged = true;
     }
 
     /**



Mime
View raw message