You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2017/02/18 19:58:02 UTC

svn commit: r1783580 - /jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java

Author: fschumacher
Date: Sat Feb 18 19:58:02 2017
New Revision: 1783580

URL: http://svn.apache.org/viewvc?rev=1783580&view=rev
Log:
Make GUI more responsive when it gets a lot of events.
Convert Graph Visualizer to use a queue, when new Samples 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. Note, that this will not save us from OOM exceptions.

Bugzilla Id: 60687


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

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java?rev=1783580&r1=1783579&r2=1783580&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java Sat Feb 18 19:58:02 2017
@@ -27,6 +27,8 @@ import java.awt.Image;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.text.NumberFormat;
+import java.util.Deque;
+import java.util.concurrent.ConcurrentLinkedDeque;
 
 import javax.swing.BorderFactory;
 import javax.swing.Box;
@@ -37,6 +39,7 @@ import javax.swing.JScrollPane;
 import javax.swing.JTextField;
 import javax.swing.ScrollPaneConstants;
 import javax.swing.SwingConstants;
+import javax.swing.Timer;
 import javax.swing.border.Border;
 import javax.swing.border.EmptyBorder;
 
@@ -94,6 +97,8 @@ public class GraphVisualizer extends Abs
 
     private JTextField medianField;
 
+    private Deque<SampleResult> newSamples = new ConcurrentLinkedDeque<>();
+
     /**
      * Constructor for the GraphVisualizer object.
      */
@@ -117,8 +122,30 @@ public class GraphVisualizer extends Abs
         return result;
     }
 
-    public synchronized void updateGui(Sample s) {
+    /**
+     * @deprecated use {@link GraphVisualizer#add(SampleResult)} instead
+     */
+    public void updateGui(Sample s) {
+        JMeterUtils.runSafe(false, () -> _updateGui(s));
+    }
+
+    // called inside AWT Thread
+    private void collectSamplesFromQueue() {
         // We have received one more sample
+        Sample s = null;
+        synchronized (graph) {
+            while (!newSamples.isEmpty()) {
+                s = model.addSample(newSamples.pop());
+            }
+        }
+        _updateGui(s);
+    }
+
+    // called inside AWT Thread
+    private void _updateGui(Sample s) {
+        if (s == null) {
+            return;
+        }
         graph.updateGui(s);
         noSamplesField.setText(Long.toString(s.getCount()));
         dataField.setText(Long.toString(s.getData()));
@@ -131,12 +158,7 @@ public class GraphVisualizer extends Abs
 
     @Override
     public void add(final SampleResult res) {
-        JMeterUtils.runSafe(false, new Runnable() {
-            @Override
-            public void run() {
-                updateGui(model.addSample(res));
-            }
-        });
+        newSamples.add(res);
     }
 
     @Override
@@ -162,8 +184,11 @@ public class GraphVisualizer extends Abs
 
     @Override
     public void clearData() {
-        graph.clearData();
-        model.clear();
+        synchronized (graph) {
+            graph.clearData();
+            model.clear();
+            newSamples.clear();
+        }
         dataField.setText(ZERO);
         averageField.setText(ZERO);
         deviationField.setText(ZERO);
@@ -208,6 +233,8 @@ public class GraphVisualizer extends Abs
         // Add the main panel and the graph
         this.add(makeTitlePanel(), BorderLayout.NORTH);
         this.add(graphPanel, BorderLayout.CENTER);
+        
+        new Timer(500, e -> collectSamplesFromQueue()).start();
     }
 
     // Methods used in creating the GUI



Re: svn commit: r1783580 - /jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java

Posted by Milamber <mi...@apache.org>.

On 18/02/2017 20:27, Felix Schumacher wrote:
> Am 18.02.2017 um 21:25 schrieb Philippe Mouawad:
>> On Sat, Feb 18, 2017 at 9:23 PM, Felix Schumacher <
>> felix.schumacher@internetallee.de> wrote:
>>
>>> Am 18.02.2017 um 21:11 schrieb Milamber:
>>>
>>>>
>>>> On 18/02/2017 19:58, fschumacher@apache.org wrote:
>>>>
>>>>> Author: fschumacher
>>>>> Date: Sat Feb 18 19:58:02 2017
>>>>> New Revision: 1783580
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=1783580&view=rev
>>>>> Log:
>>>>> Make GUI more responsive when it gets a lot of events.
>>>>> Convert Graph Visualizer to use a queue, when new Samples 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. Note, that this will not save us from OOM exceptions.
>>>>>
>>>>> Bugzilla Id: 60687
>>>>>
>>>>>
>>>>> Modified:
>>>>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/Gr
>>>>> aphVisualizer.java
>>>>>
>>>>> Modified: 
>>>>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/Gr
>>>>> aphVisualizer.java
>>>>> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org
>>>>> /apache/jmeter/visualizers/GraphVisualizer.java?rev=1783580&
>>>>> r1=1783579&r2=1783580&view=diff
>>>>> ============================================================================== 
>>>>>
>>>>>
>>>>> --- 
>>>>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java
>>>>> (original)
>>>>> +++ 
>>>>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java
>>>>> Sat Feb 18 19:58:02 2017
>>>>> @@ -27,6 +27,8 @@ import java.awt.Image;
>>>>> [snip]
>>>>> +
>>>>> +        new Timer(500, e -> collectSamplesFromQueue()).start();
>>>>>
>>>> For this bugzilla 60687, perhaps use a new property for this 
>>>> refresh time
>>>> to allow to fine the tuning directly by users.
>>>> (at least, centralize the value into a constant for all listeners)
>>>>
>>> Yes, I will do that. I thought about adding properties for each 
>>> Listener,
>>> and a fallback one, that gets used, if the special one is not set.
>>>
>>
>>
>>> For example:
>>>
>>> jmeter.loggerpanel.refresh_period=500
>>> jmeter.gui.refresh_period=500
>>>
>>> The loggerpanel one is looked up first and if not found, the
>>> jmeter.gui.refresh_period would be used.
>>>
>>> What do you think?
>>>
>> Too much properties may be overkill. 1 shared seems enough no ?
> Would be fine with me, too.

Why not, too.

>
> Felix
>>
>>> Felix
>>>
>>>
>>>>
>>>>
>>>>
>>>>        }
>>>>>          // Methods used in creating the GUI
>>>>>
>>>>>
>>>>>
>>>>>
>>
>
>


Re: svn commit: r1783580 - /jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java

Posted by Felix Schumacher <fe...@internetallee.de>.
Am 18.02.2017 um 21:25 schrieb Philippe Mouawad:
> On Sat, Feb 18, 2017 at 9:23 PM, Felix Schumacher <
> felix.schumacher@internetallee.de> wrote:
>
>> Am 18.02.2017 um 21:11 schrieb Milamber:
>>
>>>
>>> On 18/02/2017 19:58, fschumacher@apache.org wrote:
>>>
>>>> Author: fschumacher
>>>> Date: Sat Feb 18 19:58:02 2017
>>>> New Revision: 1783580
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=1783580&view=rev
>>>> Log:
>>>> Make GUI more responsive when it gets a lot of events.
>>>> Convert Graph Visualizer to use a queue, when new Samples 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. Note, that this will not save us from OOM exceptions.
>>>>
>>>> Bugzilla Id: 60687
>>>>
>>>>
>>>> Modified:
>>>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/Gr
>>>> aphVisualizer.java
>>>>
>>>> Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/Gr
>>>> aphVisualizer.java
>>>> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org
>>>> /apache/jmeter/visualizers/GraphVisualizer.java?rev=1783580&
>>>> r1=1783579&r2=1783580&view=diff
>>>> ==============================================================================
>>>>
>>>> --- jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java
>>>> (original)
>>>> +++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java
>>>> Sat Feb 18 19:58:02 2017
>>>> @@ -27,6 +27,8 @@ import java.awt.Image;
>>>> [snip]
>>>> +
>>>> +        new Timer(500, e -> collectSamplesFromQueue()).start();
>>>>
>>> For this bugzilla 60687, perhaps use a new property for this refresh time
>>> to allow to fine the tuning directly by users.
>>> (at least, centralize the value into a constant for all listeners)
>>>
>> Yes, I will do that. I thought about adding properties for each Listener,
>> and a fallback one, that gets used, if the special one is not set.
>>
>
>
>> For example:
>>
>> jmeter.loggerpanel.refresh_period=500
>> jmeter.gui.refresh_period=500
>>
>> The loggerpanel one is looked up first and if not found, the
>> jmeter.gui.refresh_period would be used.
>>
>> What do you think?
>>
> Too much properties may be overkill. 1 shared seems enough no ?
Would be fine with me, too.

Felix
>
>> Felix
>>
>>
>>>
>>>
>>>
>>>        }
>>>>          // Methods used in creating the GUI
>>>>
>>>>
>>>>
>>>>
>


Re: svn commit: r1783580 - /jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java

Posted by Philippe Mouawad <ph...@gmail.com>.
On Sat, Feb 18, 2017 at 9:23 PM, Felix Schumacher <
felix.schumacher@internetallee.de> wrote:

> Am 18.02.2017 um 21:11 schrieb Milamber:
>
>>
>>
>> On 18/02/2017 19:58, fschumacher@apache.org wrote:
>>
>>> Author: fschumacher
>>> Date: Sat Feb 18 19:58:02 2017
>>> New Revision: 1783580
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1783580&view=rev
>>> Log:
>>> Make GUI more responsive when it gets a lot of events.
>>> Convert Graph Visualizer to use a queue, when new Samples 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. Note, that this will not save us from OOM exceptions.
>>>
>>> Bugzilla Id: 60687
>>>
>>>
>>> Modified:
>>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/Gr
>>> aphVisualizer.java
>>>
>>> Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/Gr
>>> aphVisualizer.java
>>> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org
>>> /apache/jmeter/visualizers/GraphVisualizer.java?rev=1783580&
>>> r1=1783579&r2=1783580&view=diff
>>> ==============================================================================
>>>
>>> --- jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java
>>> (original)
>>> +++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java
>>> Sat Feb 18 19:58:02 2017
>>> @@ -27,6 +27,8 @@ import java.awt.Image;
>>> [snip]
>>> +
>>> +        new Timer(500, e -> collectSamplesFromQueue()).start();
>>>
>>
>> For this bugzilla 60687, perhaps use a new property for this refresh time
>> to allow to fine the tuning directly by users.
>> (at least, centralize the value into a constant for all listeners)
>>
> Yes, I will do that. I thought about adding properties for each Listener,
> and a fallback one, that gets used, if the special one is not set.
>



>
> For example:
>
> jmeter.loggerpanel.refresh_period=500
> jmeter.gui.refresh_period=500
>
> The loggerpanel one is looked up first and if not found, the
> jmeter.gui.refresh_period would be used.
>
> What do you think?
>
Too much properties may be overkill. 1 shared seems enough no ?

>
> Felix
>
>
>>
>>
>>
>>
>>       }
>>>         // Methods used in creating the GUI
>>>
>>>
>>>
>>>
>>
>


-- 
Cordialement.
Philippe Mouawad.

Re: svn commit: r1783580 - /jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java

Posted by Milamber <mi...@apache.org>.

On 18/02/2017 20:23, Felix Schumacher wrote:
> Am 18.02.2017 um 21:11 schrieb Milamber:
>>
>>
>> On 18/02/2017 19:58, fschumacher@apache.org wrote:
>>> Author: fschumacher
>>> Date: Sat Feb 18 19:58:02 2017
>>> New Revision: 1783580
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1783580&view=rev
>>> Log:
>>> Make GUI more responsive when it gets a lot of events.
>>> Convert Graph Visualizer to use a queue, when new Samples 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. Note, that this will not save us from OOM exceptions.
>>>
>>> Bugzilla Id: 60687
>>>
>>>
>>> Modified:
>>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java 
>>>
>>>
>>> Modified: 
>>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java
>>> URL: 
>>> http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java?rev=1783580&r1=1783579&r2=1783580&view=diff
>>> ============================================================================== 
>>>
>>> --- 
>>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java 
>>> (original)
>>> +++ 
>>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java 
>>> Sat Feb 18 19:58:02 2017
>>> @@ -27,6 +27,8 @@ import java.awt.Image;
>>> [snip]
>>> +
>>> +        new Timer(500, e -> collectSamplesFromQueue()).start();
>>
>> For this bugzilla 60687, perhaps use a new property for this refresh 
>> time to allow to fine the tuning directly by users.
>> (at least, centralize the value into a constant for all listeners)
> Yes, I will do that. I thought about adding properties for each 
> Listener, and a fallback one, that gets used, if the special one is 
> not set.
>
> For example:
>
> jmeter.loggerpanel.refresh_period=500
> jmeter.gui.refresh_period=500
>
> The loggerpanel one is looked up first and if not found, the 
> jmeter.gui.refresh_period would be used.
>
> What do you think?

Sound good for me. Don't forget to add the comments about the behavior 
description (and the units) inside the jmeter.properties file (and the 
documentation)
>
> Felix
>>
>>
>>
>>
>>
>>>       }
>>>         // Methods used in creating the GUI
>>>
>>>
>>>
>>
>
>


Re: svn commit: r1783580 - /jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java

Posted by Felix Schumacher <fe...@internetallee.de>.
Am 18.02.2017 um 21:11 schrieb Milamber:
>
>
> On 18/02/2017 19:58, fschumacher@apache.org wrote:
>> Author: fschumacher
>> Date: Sat Feb 18 19:58:02 2017
>> New Revision: 1783580
>>
>> URL: http://svn.apache.org/viewvc?rev=1783580&view=rev
>> Log:
>> Make GUI more responsive when it gets a lot of events.
>> Convert Graph Visualizer to use a queue, when new Samples 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. Note, that this will not save us from OOM exceptions.
>>
>> Bugzilla Id: 60687
>>
>>
>> Modified:
>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java
>>
>> Modified: 
>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java
>> URL: 
>> http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java?rev=1783580&r1=1783579&r2=1783580&view=diff
>> ============================================================================== 
>>
>> --- 
>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java 
>> (original)
>> +++ 
>> jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java 
>> Sat Feb 18 19:58:02 2017
>> @@ -27,6 +27,8 @@ import java.awt.Image;
>> [snip]
>> +
>> +        new Timer(500, e -> collectSamplesFromQueue()).start();
>
> For this bugzilla 60687, perhaps use a new property for this refresh 
> time to allow to fine the tuning directly by users.
> (at least, centralize the value into a constant for all listeners)
Yes, I will do that. I thought about adding properties for each 
Listener, and a fallback one, that gets used, if the special one is not set.

For example:

jmeter.loggerpanel.refresh_period=500
jmeter.gui.refresh_period=500

The loggerpanel one is looked up first and if not found, the 
jmeter.gui.refresh_period would be used.

What do you think?

Felix
>
>
>
>
>
>>       }
>>         // Methods used in creating the GUI
>>
>>
>>
>


Re: svn commit: r1783580 - /jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java

Posted by Milamber <mi...@apache.org>.

On 18/02/2017 19:58, fschumacher@apache.org wrote:
> Author: fschumacher
> Date: Sat Feb 18 19:58:02 2017
> New Revision: 1783580
>
> URL: http://svn.apache.org/viewvc?rev=1783580&view=rev
> Log:
> Make GUI more responsive when it gets a lot of events.
> Convert Graph Visualizer to use a queue, when new Samples 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. Note, that this will not save us from OOM exceptions.
>
> Bugzilla Id: 60687
>
>
> Modified:
>      jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java
>
> Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java?rev=1783580&r1=1783579&r2=1783580&view=diff
> ==============================================================================
> --- jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java (original)
> +++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/GraphVisualizer.java Sat Feb 18 19:58:02 2017
> @@ -27,6 +27,8 @@ import java.awt.Image;
> [snip]
> +
> +        new Timer(500, e -> collectSamplesFromQueue()).start();

For this bugzilla 60687, perhaps use a new property for this refresh 
time to allow to fine the tuning directly by users.
(at least, centralize the value into a constant for all listeners)





>       }
>   
>       // Methods used in creating the GUI
>
>
>