jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1778949 - in /jmeter/trunk: bin/ src/components/org/apache/jmeter/visualizers/backend/ xdocs/ xdocs/usermanual/
Date Sun, 15 Jan 2017 21:56:37 GMT
Author: pmouawad
Date: Sun Jan 15 21:56:37 2017
New Revision: 1778949

URL: http://svn.apache.org/viewvc?rev=1778949&view=rev
Log:
Bug 60591 - BackendListener : Add a time boxed sampling 
Based on PR 237  from by Logan Mauzaize (logan.mauzaize at gmail.com) and
Maxime Chassagneux (maxime.chassagneux at gmail.com).

Changes in PR:
- Add documentation in properties_reference.xml
- Make some fields static

This closes #237
Bugzilla Id: 60591

Added:
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/WindowMode.java   (with
props)
Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.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=1778949&r1=1778948&r2=1778949&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Sun Jan 15 21:56:37 2017
@@ -917,6 +917,8 @@ summariser.name=summary
 # BackendListener - configuration
 #---------------------------------------------------------------------------
 #
+# Backend metrics window mode (fixed=fixed-size window, timed=time boxed) 
+#backend_metrics_window_mode=fixed
 # Backend metrics sliding window size for Percentiles, Min, Max
 #backend_metrics_window=100
 

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.java?rev=1778949&r1=1778948&r2=1778949&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.java Sun
Jan 15 21:56:37 2017
@@ -18,6 +18,11 @@
 
 package org.apache.jmeter.visualizers.backend;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
 import org.apache.jmeter.control.TransactionController;
 import org.apache.jmeter.samplers.SampleResult;
@@ -28,24 +33,57 @@ import org.apache.jmeter.util.JMeterUtil
  * @since 2.13
  */
 public class SamplerMetric {
-    private static final int SLIDING_WINDOW_SIZE = JMeterUtils.getPropDefault("backend_metrics_window",
100); //$NON-NLS-1$
-    
-    // Response times for OK samples
-    // Limit to sliding window of SLIDING_WINDOW_SIZE values 
-    private DescriptiveStatistics okResponsesStats = new DescriptiveStatistics(SLIDING_WINDOW_SIZE);
-    // Response times for KO samples
-    // Limit to sliding window of SLIDING_WINDOW_SIZE values 
-    private DescriptiveStatistics koResponsesStats = new DescriptiveStatistics(SLIDING_WINDOW_SIZE);
-    // Response times for All samples
-    // Limit to sliding window of SLIDING_WINDOW_SIZE values 
-    private DescriptiveStatistics allResponsesStats = new DescriptiveStatistics(SLIDING_WINDOW_SIZE);
+    private static final int SLIDING_WINDOW_SIZE = JMeterUtils.getPropDefault("backend_metrics_window",
100);
+
+    private static final WindowMode WINDOW_MODE = WindowMode.get();
+
+    /**
+     * Response times for OK samples
+     */
+    private DescriptiveStatistics okResponsesStats = new DescriptiveStatistics();
+    /**
+     * Response times for KO samples
+     */
+    private DescriptiveStatistics koResponsesStats = new DescriptiveStatistics();
+    /**
+     * Response times for All samples
+     */
+    private DescriptiveStatistics allResponsesStats = new DescriptiveStatistics();
+    /**
+     *  OK, KO, ALL stats if WindowMode is FIXED
+     */
+    private List<DescriptiveStatistics> windowedStats = initWindowedStats();
+    /**
+     * Timeboxed percentiles don't makes sense
+     */
+    private DescriptiveStatistics pctResponseStats = new DescriptiveStatistics();
     private int successes;
     private int failures;
     private int hits;
+    
     /**
      * 
      */
     public SamplerMetric() {
+    	List<DescriptiveStatistics> stats = new ArrayList<>(4);
+    	stats.add(pctResponseStats);
+    	stats.addAll(windowedStats);
+
+    	// Limit to sliding window of SLIDING_WINDOW_SIZE values
+		for (DescriptiveStatistics stat : stats) {
+    		stat.setWindowSize(SLIDING_WINDOW_SIZE);
+    	}
+    }
+
+    /**
+     * @return List of {@link DescriptiveStatistics}
+     */
+    private List<DescriptiveStatistics> initWindowedStats() {
+        if (WINDOW_MODE == WindowMode.FIXED) {
+            return Arrays.asList(okResponsesStats, koResponsesStats, allResponsesStats);
+        } else {
+            return Collections.emptyList();
+        }
     }
 
     /**
@@ -60,6 +98,7 @@ public class SamplerMetric {
         }
         long time = result.getTime();
         allResponsesStats.addValue(time);
+        pctResponseStats.addValue(time);
         if(result.isSuccessful()) {
             // Should we also compute KO , all response time ?
             // only take successful requests for time computing
@@ -88,8 +127,19 @@ public class SamplerMetric {
      * Reset metric except for percentile related data
      */
     public synchronized void resetForTimeInterval() {
-        // We don't clear responsesStats nor usersStats as it will slide as per my understanding
of 
-        // http://commons.apache.org/proper/commons-math/userguide/stat.html
+    	switch (WINDOW_MODE) {
+    		case FIXED:
+                // We don't clear responsesStats nor usersStats as it will slide as per my
understanding of 
+                // http://commons.apache.org/proper/commons-math/userguide/stat.html
+    			break;
+    		case TIMED:
+    			for (DescriptiveStatistics stat : windowedStats) {
+    				stat.clear();
+    			}
+    			break;
+			default: 
+			    // This cannot happen
+    	}
         successes = 0;
         failures = 0;
         hits = 0;
@@ -242,7 +292,7 @@ public class SamplerMetric {
      *         values.
      */
     public double getAllPercentile(double percentile) {
-        return allResponsesStats.getPercentile(percentile);
+        return pctResponseStats.getPercentile(percentile);
     }
 
     /**

Added: jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/WindowMode.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/WindowMode.java?rev=1778949&view=auto
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/WindowMode.java (added)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/WindowMode.java Sun
Jan 15 21:56:37 2017
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.visualizers.backend;
+
+import org.apache.jmeter.util.JMeterUtils;
+
+/**
+ * Metrics are sent into boxes which can be {@link #FIXED a fixed-size sliding window} or
{@link #TIMED time boxed}.
+ * @since 3.2
+ */
+public enum WindowMode {
+	/** Fixed-size sliding window. **/
+	FIXED,
+	/** Time boxed. **/
+	TIMED;
+
+	/**
+	 * Gets defined JMeter mode.
+	 */
+	public static WindowMode get() {
+		String name = JMeterUtils.getPropDefault("backend_metrics_window_mode", FIXED.name());
+		return WindowMode.valueOf(name.toUpperCase());
+	}
+}

Propchange: jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/WindowMode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1778949&r1=1778948&r2=1778949&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Sun Jan 15 21:56:37 2017
@@ -126,6 +126,7 @@ JMeter now requires Java 8. Ensure you u
     <li><bug>60542</bug>View Results Tree : Allow Upper Panel to be collapsed.
Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
     <li><bug>52962</bug>Allow sorting by columns for View Results in Table,
Summary Report, Aggregate Report and Aggregate Graph. Based on a <pr>245</pr>
by Logan Mauzaize (logan.mauzaize at gmail.com) and Maxime Chassagneux (maxime.chassagneux
at gmail.com).</li>
     <li><bug>60590</bug>BackendListener : Add Influxdb BackendListenerClient
implementation to JMeter. Partly based on <pr>246</pr> by Logan Mauzaize (logan.mauzaize
at gmail.com) and Maxime Chassagneux (maxime.chassagneux at gmail.com).</li>
+    <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>
 </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=1778949&r1=1778948&r2=1778949&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/properties_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/properties_reference.xml Sun Jan 15 21:56:37 2017
@@ -1129,6 +1129,15 @@ log_level.org.apache.http.client=DEBUG
     and <code>Max</code>.<br/>
     Defaults to: <code>100</code>
 </property>
+<property name="backend_metrics_window">
+    Backend metrics window mode.
+    Possible values:
+    <ul>
+        <li><code>fixed</code> : fixed-size window</li>
+        <li><code>timed</code> : time boxed</li>
+    </ul>
+    Defaults to: <code>fixed</code>
+</property>
 </properties>
 </section>
 <section name="&sect-num;.32 BeanShell configuration" anchor="beanshell">



Mime
View raw message