You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Philippe Mouawad <ph...@gmail.com> on 2021/06/04 18:38:11 UTC

Re: [jmeter] branch master updated: Make the estimator used for calculating percentiles on the dashboard configurable

Hello Felix,
Thanks for this fix.

I saw a little typo in:
To make the values from the dashboard compatible with the Aggragate Report,
use the value <code>R_3</code>.<br/>
Should be:
To make the values from the dashboard compatible with the Aggregate Report,
use the value <code>R_3</code>.<br/>

Regards
On Thu, Jun 3, 2021 at 7:39 PM <fs...@apache.org> wrote:

> This is an automated email from the ASF dual-hosted git repository.
>
> fschumacher pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/jmeter.git
>
>
> The following commit(s) were added to refs/heads/master by this push:
>      new 1647a2b  Make the estimator used for calculating percentiles on
> the dashboard configurable
> 1647a2b is described below
>
> commit 1647a2b0cb69c2bae415d22816df0065403f44a6
> Author: Felix Schumacher <fe...@internetallee.de>
> AuthorDate: Thu Jun 3 19:32:17 2021 +0200
>
>     Make the estimator used for calculating percentiles on the dashboard
> configurable
>
>     Bugzilla Id: 65353
> ---
>  .../jmeter/visualizers/backend/SamplerMetric.java  |  9 +++--
>  .../jmeter/visualizers/backend/UserMetric.java     |  5 ++-
>  .../processor/DescriptiveStatisticsFactory.java    | 43
> ++++++++++++++++++++++
>  .../report/processor/PercentileAggregator.java     |  4 +-
>  xdocs/changes.xml                                  |  1 +
>  xdocs/usermanual/properties_reference.xml          |  6 ++-
>  6 files changed, 60 insertions(+), 8 deletions(-)
>
> diff --git
> a/src/components/src/main/java/org/apache/jmeter/visualizers/backend/SamplerMetric.java
> b/src/components/src/main/java/org/apache/jmeter/visualizers/backend/SamplerMetric.java
> index a279310..0ae60fb 100644
> ---
> a/src/components/src/main/java/org/apache/jmeter/visualizers/backend/SamplerMetric.java
> +++
> b/src/components/src/main/java/org/apache/jmeter/visualizers/backend/SamplerMetric.java
> @@ -24,6 +24,7 @@ import java.util.Map;
>
>  import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
>  import org.apache.jmeter.control.TransactionController;
> +import org.apache.jmeter.report.processor.DescriptiveStatisticsFactory;
>  import org.apache.jmeter.samplers.SampleResult;
>  import org.apache.jmeter.util.JMeterUtils;
>  import org.apache.jorphan.documentation.VisibleForTesting;
> @@ -41,15 +42,15 @@ public class SamplerMetric {
>      /**
>       * Response times for OK samples
>       */
> -    private DescriptiveStatistics okResponsesStats = new
> DescriptiveStatistics(LARGE_SLIDING_WINDOW_SIZE);
> +    private DescriptiveStatistics okResponsesStats =
> DescriptiveStatisticsFactory.createDescriptiveStatistics(LARGE_SLIDING_WINDOW_SIZE);
>      /**
>       * Response times for KO samples
>       */
> -    private DescriptiveStatistics koResponsesStats = new
> DescriptiveStatistics(LARGE_SLIDING_WINDOW_SIZE);
> +    private DescriptiveStatistics koResponsesStats =
> DescriptiveStatisticsFactory.createDescriptiveStatistics(LARGE_SLIDING_WINDOW_SIZE);
>      /**
>       * Response times for All samples
>       */
> -    private DescriptiveStatistics allResponsesStats = new
> DescriptiveStatistics(LARGE_SLIDING_WINDOW_SIZE);
> +    private DescriptiveStatistics allResponsesStats =
> DescriptiveStatisticsFactory.createDescriptiveStatistics(LARGE_SLIDING_WINDOW_SIZE);
>      /**
>       *  OK, KO, ALL stats
>       */
> @@ -57,7 +58,7 @@ public class SamplerMetric {
>      /**
>       * Timeboxed percentiles don't makes sense
>       */
> -    private DescriptiveStatistics pctResponseStats = new
> DescriptiveStatistics(SLIDING_WINDOW_SIZE);
> +    private DescriptiveStatistics pctResponseStats =
> DescriptiveStatisticsFactory.createDescriptiveStatistics(SLIDING_WINDOW_SIZE);
>      private int successes;
>      private int failures;
>      private int hits;
> diff --git
> a/src/components/src/main/java/org/apache/jmeter/visualizers/backend/UserMetric.java
> b/src/components/src/main/java/org/apache/jmeter/visualizers/backend/UserMetric.java
> index 1358962..1c84707 100644
> ---
> a/src/components/src/main/java/org/apache/jmeter/visualizers/backend/UserMetric.java
> +++
> b/src/components/src/main/java/org/apache/jmeter/visualizers/backend/UserMetric.java
> @@ -18,6 +18,7 @@
>  package org.apache.jmeter.visualizers.backend;
>
>  import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
> +import org.apache.jmeter.report.processor.DescriptiveStatisticsFactory;
>  import org.apache.jmeter.samplers.SampleResult;
>  import org.apache.jmeter.threads.JMeterContextService;
>  import org.apache.jmeter.util.JMeterUtils;
> @@ -27,10 +28,12 @@ import org.apache.jmeter.util.JMeterUtils;
>   * @since 2.13
>   */
>  public class UserMetric {
> +
>      private static final int SLIDING_WINDOW_SIZE =
> JMeterUtils.getPropDefault("backend_metrics_window", 100); //$NON-NLS-1$
>
>      // Limit to sliding window of SLIDING_WINDOW_SIZE values
> -    private DescriptiveStatistics usersStats = new
> DescriptiveStatistics(SLIDING_WINDOW_SIZE);
> +    private DescriptiveStatistics usersStats =
> DescriptiveStatisticsFactory.createDescriptiveStatistics(SLIDING_WINDOW_SIZE);
> +
>      /**
>       *
>       */
> diff --git
> a/src/core/src/main/java/org/apache/jmeter/report/processor/DescriptiveStatisticsFactory.java
> b/src/core/src/main/java/org/apache/jmeter/report/processor/DescriptiveStatisticsFactory.java
> new file mode 100644
> index 0000000..7b03408
> --- /dev/null
> +++
> b/src/core/src/main/java/org/apache/jmeter/report/processor/DescriptiveStatisticsFactory.java
> @@ -0,0 +1,43 @@
> +/*
> + * 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.report.processor;
> +
> +import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
> +import org.apache.commons.math3.stat.descriptive.rank.Percentile;
> +import
> org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType;
> +import org.apache.jmeter.util.JMeterUtils;
> +
> +public class DescriptiveStatisticsFactory {
> +    private static final int SLIDING_WINDOW_SIZE =
> JMeterUtils.getPropDefault("backend_metrics_window", 100); //$NON-NLS-1$
> +    private static final EstimationType ESTIMATION_TYPE = EstimationType
> +
> .valueOf(JMeterUtils.getPropDefault("backend_metrics_percentile_estimator",
> "LEGACY")); //$NON-NLS-1$
> +
> +    private DescriptiveStatisticsFactory() {
> +        // utility class -> hide the constructor
> +    }
> +
> +    public static DescriptiveStatistics createDescriptiveStatistics() {
> +        return createDescriptiveStatistics(SLIDING_WINDOW_SIZE);
> +    }
> +
> +    public static DescriptiveStatistics createDescriptiveStatistics(int
> windowSize) {
> +        DescriptiveStatistics statistics = new DescriptiveStatistics();
> +        statistics.setPercentileImpl(new
> Percentile().withEstimationType(ESTIMATION_TYPE));
> +        return statistics;
> +    }
> +}
> diff --git
> a/src/core/src/main/java/org/apache/jmeter/report/processor/PercentileAggregator.java
> b/src/core/src/main/java/org/apache/jmeter/report/processor/PercentileAggregator.java
> index 44fbe0e..ca81b2e 100644
> ---
> a/src/core/src/main/java/org/apache/jmeter/report/processor/PercentileAggregator.java
> +++
> b/src/core/src/main/java/org/apache/jmeter/report/processor/PercentileAggregator.java
> @@ -42,7 +42,7 @@ public class PercentileAggregator implements Aggregator {
>       *            the index of the percentile
>       */
>      public PercentileAggregator(double index) {
> -        statistics = new DescriptiveStatistics(SLIDING_WINDOW_SIZE);
> +        statistics =
> DescriptiveStatisticsFactory.createDescriptiveStatistics(SLIDING_WINDOW_SIZE);
>          percentileIndex = index;
>      }
>
> @@ -50,7 +50,7 @@ public class PercentileAggregator implements Aggregator {
>       * @param lastAggregator {@link PercentileAggregator}
>       */
>      public PercentileAggregator(PercentileAggregator lastAggregator) {
> -        statistics = new DescriptiveStatistics(SLIDING_WINDOW_SIZE);
> +        statistics =
> DescriptiveStatisticsFactory.createDescriptiveStatistics(SLIDING_WINDOW_SIZE);
>          this.percentileIndex = lastAggregator.percentileIndex;
>      }
>
> diff --git a/xdocs/changes.xml b/xdocs/changes.xml
> index 46bbf8f..aa03e32 100644
> --- a/xdocs/changes.xml
> +++ b/xdocs/changes.xml
> @@ -121,6 +121,7 @@ Summary
>
>  <h3>Report / Dashboard</h3>
>  <ul>
> +  <li><bug>65353</bug>Make the estimator used for calculating percentiles
> on the dashboard configurable</li>
>  </ul>
>
>  <h3>General</h3>
> diff --git a/xdocs/usermanual/properties_reference.xml
> b/xdocs/usermanual/properties_reference.xml
> index de95a86..5e1565d 100644
> --- a/xdocs/usermanual/properties_reference.xml
> +++ b/xdocs/usermanual/properties_reference.xml
> @@ -1161,7 +1161,11 @@ JMETER-SERVER</source>
>      Setting this value too high can lead to OOM Backend metrics sliding
> window size
>      Defaults to: <code>5000</code>
>  </property>
> -
> +<property name="backend_metrics_percentile_estimator">
> +    Specify the <a href="
> https://commons.apache.org/proper/commons-math/javadocs/api-3.5/org/apache/commons/math3/stat/descriptive/rank/Percentile.EstimationType.html">Percentile
> Estimation Type</a> to use.<br/>
> +    To make the values from the dashboard compatible with the Aggragate
> Report, use the value <code>R_3</code>.<br/>
> +    Defaults to: <code>LEGACY</code>
> +</property>
>  <property name="backend_metrics_window_mode">
>      Backend metrics window mode.
>      Possible values:
>


-- 
Cordialement.
Philippe Mouawad.