jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1782229 - in /jmeter/trunk: bin/jmeter.properties src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java xdocs/usermanual/properties_reference.xml
Date Wed, 08 Feb 2017 19:00:26 GMT
Author: fschumacher
Date: Wed Feb  8 19:00:26 2017
New Revision: 1782229

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

Bugzilla Id: 60687


Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java
    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=1782229&r1=1782228&r2=1782229&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Wed Feb  8 19:00:26 2017
@@ -1076,6 +1076,12 @@ cookies=cookies
 # prefixed with org.apache.jmeter.visualizers
 view.results.tree.renderers_order=.RenderAsText,.RenderAsRegexp,.RenderAsCssJQuery,.RenderAsXPath,org.apache.jmeter.extractor.json.render.RenderAsJsonRenderer,.RenderAsHTML,.RenderAsHTMLFormatted,.RenderAsHTMLWithEmbedded,.RenderAsDocument,.RenderAsJSON,.RenderAsXML
 
+# Period after which the results tree should be refreshed
+#view.results.tree.update_period=500
+
+# Maximum number of results in the results tree
+#view.results.tree.max_results=100
+
 # Maximum size of Document that can be parsed by Tika engine; defaut=10 * 1024 * 1024 (10MB)
 # Set to 0 to disable the size check
 #document.max_size=0

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java?rev=1782229&r1=1782228&r2=1782229&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java
(original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java
Wed Feb  8 19:00:26 2017
@@ -33,6 +33,7 @@ import java.awt.event.ItemListener;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -46,6 +47,7 @@ import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
 import javax.swing.JTabbedPane;
 import javax.swing.JTree;
+import javax.swing.Timer;
 import javax.swing.border.Border;
 import javax.swing.event.TreeSelectionEvent;
 import javax.swing.event.TreeSelectionListener;
@@ -55,6 +57,7 @@ import javax.swing.tree.DefaultTreeModel
 import javax.swing.tree.TreePath;
 import javax.swing.tree.TreeSelectionModel;
 
+import org.apache.commons.collections.buffer.BoundedFifoBuffer;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.JMeter;
 import org.apache.jmeter.assertions.AssertionResult;
@@ -124,42 +127,70 @@ implements ActionListener, TreeSelection
     private static final String VIEWERS_ORDER =
         JMeterUtils.getPropDefault("view.results.tree.renderers_order", ""); // $NON-NLS-1$
//$NON-NLS-2$
 
+    private static final int REFRESH_PERIOD = JMeterUtils.getPropDefault("view.results.tree.refresh_period",
500);
+
     private ResultRenderer resultsRender = null;
 
     private TreeSelectionEvent lastSelectionEvent;
 
     private JCheckBox autoScrollCB;
 
+    private BoundedFifoBuffer buffer = new BoundedFifoBuffer(JMeterUtils.getPropDefault("view.results.tree.max_results",
500));
+
+    private boolean dataChanged;
+
     /**
      * Constructor
      */
     public ViewResultsFullVisualizer() {
         super();
         init();
+        new Timer(REFRESH_PERIOD, e -> {
+            updateGui();
+        }).start();
     }
 
     /** {@inheritDoc} */
     @Override
     public void add(final SampleResult sample) {
-        JMeterUtils.runSafe(false, ()-> updateGui(sample));
+        synchronized (buffer) {
+            if (buffer.isFull()) {
+                buffer.remove();
+            }
+            buffer.add(sample);
+            dataChanged = true;
+        }
     }
 
     /**
      * Update the visualizer with new data.
      */
-    private synchronized void updateGui(SampleResult res) {
-        // Add sample
-        DefaultMutableTreeNode currNode = new SearchableTreeNode(res, treeModel);
-        treeModel.insertNodeInto(currNode, root, root.getChildCount());
-        addSubResults(currNode, res);
-        // Add any assertion that failed as children of the sample node
-        AssertionResult[] assertionResults = res.getAssertionResults();
-        int assertionIndex = currNode.getChildCount();
-        for (AssertionResult assertionResult : assertionResults) {
-            if (assertionResult.isFailure() || assertionResult.isError()) {
-                DefaultMutableTreeNode assertionNode = new SearchableTreeNode(assertionResult,
treeModel);
-                treeModel.insertNodeInto(assertionNode, currNode, assertionIndex++);
+    private void updateGui() {
+        synchronized (buffer) {
+            if (!dataChanged) {
+                return;
+            }
+            root.removeAllChildren();
+            @SuppressWarnings("unchecked")
+            Iterator<SampleResult> samplers = buffer.iterator();
+            while (samplers.hasNext()) {
+                SampleResult res = (SampleResult) samplers.next();
+                // Add sample
+                DefaultMutableTreeNode currNode = new SearchableTreeNode(res, treeModel);
+                treeModel.insertNodeInto(currNode, root, root.getChildCount());
+                addSubResults(currNode, res);
+                // Add any assertion that failed as children of the sample node
+                AssertionResult[] assertionResults = res.getAssertionResults();
+                int assertionIndex = currNode.getChildCount();
+                for (AssertionResult assertionResult : assertionResults) {
+                    if (assertionResult.isFailure() || assertionResult.isError()) {
+                        DefaultMutableTreeNode assertionNode = new SearchableTreeNode(assertionResult,
treeModel);
+                        treeModel.insertNodeInto(assertionNode, currNode, assertionIndex++);
+                    }
+                }
             }
+            treeModel.nodeStructureChanged(root);
+            dataChanged = false;
         }
 
         if (root.getChildCount() == 1) {
@@ -196,11 +227,10 @@ implements ActionListener, TreeSelection
 
     /** {@inheritDoc} */
     @Override
-    public synchronized void clearData() {
-        while (root.getChildCount() > 0) {
-            // the child to be removed will always be 0 'cos as the nodes are
-            // removed the nth node will become (n-1)th
-            treeModel.removeNodeFromParent((DefaultMutableTreeNode) root.getChildAt(0));
+    public void clearData() {
+        synchronized (buffer) {
+            buffer.clear();
+            dataChanged = true;
         }
         resultsRender.clearData();
     }

Modified: jmeter/trunk/xdocs/usermanual/properties_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/properties_reference.xml?rev=1782229&r1=1782228&r2=1782229&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/properties_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/properties_reference.xml Wed Feb  8 19:00:26 2017
@@ -1455,6 +1455,10 @@ log_level.org.apache.http.client=DEBUG
     for the Console Logger panel.<br/>
     Defaults to: <code>true</code>
 </property>
+<property name="view.results.tree.max_results">
+    Maximum number of main samples, that should be stored and displayed.<br/>
+    Defaults to: <code>500</code>
+</property>
 <property name="view.results.tree.max_size">
     Maximum size (in bytes) of HTML page that can be displayed.<br/>
     Set to zero to disable the size check and display the whole response.<br/>
@@ -1468,6 +1472,9 @@ log_level.org.apache.http.client=DEBUG
     Defaults to:
     <source>.RenderAsText,.RenderAsRegexp,.RenderAsCssJQuery,.RenderAsXPath,.RenderAsHTML,.RenderAsHTMLWithEmbedded,.RenderAsDocument,.RenderAsJSON,.RenderAsXML</source>
 </property>
+<property name="view.results.tree.refresh_period">
+    Interval in <code>ms</code> after which the results should be updated.<br/>
+    Defaults to: <code>500</code></property>
 <property name="document.max_size">
     Maximum size (in bytes) of Document that can be parsed by Tika engine<br/>
     Set to zero to disable the size check.<br/>



Mime
View raw message