jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1782227 - in /jmeter/trunk: bin/jmeter.properties src/core/org/apache/jmeter/gui/LoggerPanel.java xdocs/changes.xml xdocs/usermanual/properties_reference.xml
Date Wed, 08 Feb 2017 18:47:24 GMT
Author: fschumacher
Date: Wed Feb  8 18:47:24 2017
New Revision: 1782227

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

Bugzilla Id: 60687

Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/core/org/apache/jmeter/gui/LoggerPanel.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/properties_reference.xml

Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1782227&r1=1782226&r2=1782227&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Wed Feb  8 18:47:24 2017
@@ -129,9 +129,12 @@ jmeter.laf.mac=System
 # not be used for Load Test it is acceptable
 #jmeter.loggerpanel.enable_when_closed=true
 
-# Max characters kept in LoggerPanel, default to 80000 chars
+# Max lines kept in LoggerPanel, default to 1000 chars
 # 0 means no limit
-#jmeter.loggerpanel.maxlength=80000
+#jmeter.loggerpanel.maxlength=1000
+
+# Interval in ms to refresh the log entries in the panel.
+#jmeter.loggerpanel.refresh_period=500
 
 # HiDPI mode (default: false)
 # Activate a 'pseudo'-hidpi mode. Allows to increase size of some UI elements
@@ -1222,4 +1225,4 @@ jmeter.reportgenerator.apdex_tolerated_t
 #naming_policy.suffix
 
 # Implementation of interface org.apache.jmeter.gui.action.TreeNodeNamingPolicy
-#naming_policy.impl=org.apache.jmeter.gui.action.impl.DefaultTreeNodeNamingPolicy
\ No newline at end of file
+#naming_policy.impl=org.apache.jmeter.gui.action.impl.DefaultTreeNodeNamingPolicy

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/LoggerPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/LoggerPanel.java?rev=1782227&r1=1782226&r2=1782227&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/LoggerPanel.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/LoggerPanel.java Wed Feb  8 18:47:24 2017
@@ -20,13 +20,16 @@ package org.apache.jmeter.gui;
 
 import java.awt.BorderLayout;
 import java.awt.Insets;
+import java.util.Iterator;
 
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTextArea;
 import javax.swing.ScrollPaneConstants;
 import javax.swing.SwingUtilities;
+import javax.swing.Timer;
 
+import org.apache.commons.collections.buffer.BoundedFifoBuffer;
 import org.apache.jmeter.gui.logging.GuiLogEventListener;
 import org.apache.jmeter.gui.logging.LogEventObject;
 import org.apache.jmeter.gui.util.JSyntaxTextArea;
@@ -45,12 +48,22 @@ public class LoggerPanel extends JPanel
 
     // Limit length of log content
     private static final int LOGGER_PANEL_MAX_LENGTH =
-            JMeterUtils.getPropDefault("jmeter.loggerpanel.maxlength", 80000); // $NON-NLS-1$
-    
+            JMeterUtils.getPropDefault("jmeter.loggerpanel.maxlength", 1000); // $NON-NLS-1$
+
     // Make panel handle event even if closed
     private static final boolean LOGGER_PANEL_RECEIVE_WHEN_CLOSED =
             JMeterUtils.getPropDefault("jmeter.loggerpanel.enable_when_closed", true); //
$NON-NLS-1$
 
+    private static final int LOGGER_PANEL_REFRESH_PERIOD =
+            JMeterUtils.getPropDefault("jmeter.loggerpanel.refresh_period", 500); // $NON-NLS-1$
+
+    private final BoundedFifoBuffer events =
+            new BoundedFifoBuffer(valueOrMax(LOGGER_PANEL_MAX_LENGTH, 2000)); // $NON-NLS-1$
+
+    private volatile boolean logChanged = false;
+
+    private Timer timer;
+
     /**
      * Pane for display JMeter log file
      */
@@ -58,6 +71,13 @@ public class LoggerPanel extends JPanel
         textArea = init();
     }
 
+    private static int valueOrMax(int value, int max) {
+        if (value > 0) {
+            return value;
+        }
+        return max;
+    }
+
     private JTextArea init() { // WARNING: called from ctor so must not be overridden (i.e.
must be private or final)
         this.setLayout(new BorderLayout());
         final JScrollPane areaScrollPane;
@@ -84,6 +104,9 @@ public class LoggerPanel extends JPanel
         areaScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
         areaScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
         this.add(areaScrollPane, BorderLayout.CENTER);
+
+        initWorker();
+
         return jTextArea;
     }
 
@@ -96,27 +119,55 @@ public class LoggerPanel extends JPanel
             return;
         }
 
-        SwingUtilities.invokeLater(new Runnable() {
-            @Override
-            public void run() {
-                synchronized (textArea) {
-                    textArea.append(logEventObject.toString());
-                    int currentLength = textArea.getText().length();
-                    // If LOGGER_PANEL_MAX_LENGTH is 0, it means all log events are kept
-                    if(LOGGER_PANEL_MAX_LENGTH != 0 && currentLength> LOGGER_PANEL_MAX_LENGTH)
{
-                        textArea.setText(textArea.getText().substring(Math.max(0, currentLength-LOGGER_PANEL_MAX_LENGTH),

-                                currentLength));
+        String logMessage = logEventObject.toString();
+        synchronized (events) {
+            if (events.isFull()) {
+                events.remove();
+            }
+            events.add(logMessage);
+        }
+
+        logChanged = true;
+    }
+
+    private void initWorker() {
+        timer = new Timer(
+            LOGGER_PANEL_REFRESH_PERIOD,
+            e -> {
+                if (logChanged) {
+                    logChanged = false;
+                    StringBuilder builder = new StringBuilder();
+                    synchronized (events) {
+                        Iterator<String> lines = events.iterator();
+                        while (lines.hasNext()) {
+                            builder.append(lines.next());
+                        }
+                    }
+                    String logText = builder.toString();
+                    synchronized (textArea) {
+                        int currentLength;
+                        if (LOGGER_PANEL_MAX_LENGTH > 0) {
+                            textArea.setText(logText);
+                            currentLength = logText.length();
+                        } else {
+                            textArea.append(logText);
+                            currentLength = textArea.getText().length();
+                        }
+                        textArea.setCaretPosition(currentLength);
                     }
-                    textArea.setCaretPosition(textArea.getText().length());
                 }
             }
-        });
+        );
+        timer.start();
     }
 
     /**
      * Clear panel content
      */
     public void clear() {
-        this.textArea.setText(""); // $NON-NLS-1$
+        synchronized (events) {
+            events.clear();
+        }
+        logChanged = true;
     }
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1782227&r1=1782226&r2=1782227&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Wed Feb  8 18:47:24 2017
@@ -153,6 +153,7 @@ JMeter now requires Java 8. Ensure you u
     <li><bug>60591</bug>BackendListener : Add a time boxed sampling. Based
on a <pr>237</pr> by Logan Mauzaize (logan.mauzaize at gmail.com) and Maxime Chassagneux
(maxime.chassagneux at gmail.com).</li>
     <li><bug>60678</bug>View Results Tree : Text renderer, search should
not popup "Text Not Found"</li>
     <li><bug>60691</bug>View Results Tree : In Renderers (XPath, JSON Path
Tester, RegExp Tester and CSS/JQuery Tester) lower panel is sometimes not visible as upper
panel is too big and cannot be resized</li>
+    <li><bug>60687</bug>Keep GUI responsive when many events are processed
by View Results Tree, Summary Table and Log Panel.</li>
 </ul>
 
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>

Modified: jmeter/trunk/xdocs/usermanual/properties_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/properties_reference.xml?rev=1782227&r1=1782226&r2=1782227&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/properties_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/properties_reference.xml Wed Feb  8 18:47:24 2017
@@ -158,8 +158,11 @@ The <code>system.properties</code> file
     <note>Note this has some impact on performances, but as GUI mode must not be used
for Load Test it is acceptable</note>
     Defaults to: <code>true</code></property>
 <property name="jmeter.loggerpanel.maxlength">
-     Max characters kept in LoggerPanel, <code>0</code> means no limit.<br/>
-     Defaults to: <code>80000</code></property>
+     Max lines kept in LoggerPanel, <code>0</code> means no limit.<br/>
+     Defaults to: <code>1000</code></property>
+<property name="jmeter.loggerpanel.refresh_period">
+    Interval in <code>ms</code> to refresh the log entries in the panel.<br/>
+    Defaults to: <code>500</code></property>
 </properties>
 </section>
 <section name="&sect-num;.5 Toolbar display" anchor="toolbar_display">



Mime
View raw message