jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Mouawad <philippe.moua...@gmail.com>
Subject Re: svn commit: r1648146 - in /jmeter/trunk: src/core/org/apache/jmeter/reporters/Summariser.java src/core/org/apache/jmeter/reporters/SummariserRunningSample.java xdocs/changes.xml
Date Sun, 28 Dec 2014 14:03:17 GMT
Hi sebb,
Nice you fixed it.

Few notes:
- I have updated javadocs and removed index useless field
- Any reason for keeping AccumListener and RunningSample ? They do not look
to be used ?

Regards
Philippe


On Sun, Dec 28, 2014 at 3:55 AM, <sebb@apache.org> wrote:

> Author: sebb
> Date: Sun Dec 28 02:55:22 2014
> New Revision: 1648146
>
> URL: http://svn.apache.org/r1648146
> Log:
> Summariser : The + (difference) reports show wrong elapsed time and
> throughput
> Bugzilla Id: 57346
>
> Added:
>
> jmeter/trunk/src/core/org/apache/jmeter/reporters/SummariserRunningSample.java
> Modified:
>     jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java
>     jmeter/trunk/xdocs/changes.xml
>
> Modified: jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java?rev=1648146&r1=1648145&r2=1648146&view=diff
>
> ==============================================================================
> --- jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java
> (original)
> +++ jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java Sun
> Dec 28 02:55:22 2014
> @@ -35,7 +35,6 @@ import org.apache.jmeter.testelement.Tes
>  import org.apache.jmeter.threads.JMeterContextService;
>  import org.apache.jmeter.threads.JMeterContextService.ThreadCounts;
>  import org.apache.jmeter.util.JMeterUtils;
> -import org.apache.jmeter.visualizers.RunningSample;
>  import org.apache.jorphan.logging.LoggingManager;
>  import org.apache.jorphan.util.JOrphanUtils;
>  import org.apache.log.Logger;
> @@ -147,9 +146,9 @@ public class Summariser extends Abstract
>          /** Time of last summary (to prevent double reporting) */
>          private long last = 0;
>
> -        private final RunningSample delta = new RunningSample("DELTA",0);
> +        private final SummariserRunningSample delta = new
> SummariserRunningSample("DELTA",0);
>
> -        private final RunningSample total = new RunningSample("TOTAL",0);
> +        private final SummariserRunningSample total = new
> SummariserRunningSample("TOTAL",0);
>
>          /**
>           * Add the delta values to the total values and clear the delta
> @@ -172,8 +171,8 @@ public class Summariser extends Abstract
>
>          long now = System.currentTimeMillis() / 1000;// in seconds
>
> -        RunningSample myDelta = null;
> -        RunningSample myTotal = null;
> +        SummariserRunningSample myDelta = null;
> +        SummariserRunningSample myTotal = null;
>          boolean reportNow = false;
>
>          /*
> @@ -190,9 +189,9 @@ public class Summariser extends Abstract
>                  reportNow = true;
>
>                  // copy the data to minimise the synch time
> -                myDelta = new RunningSample(myTotals.delta);
> +                myDelta = new SummariserRunningSample(myTotals.delta);
>                  myTotals.moveDelta();
> -                myTotal = new RunningSample(myTotals.total);
> +                myTotal = new SummariserRunningSample(myTotals.total);
>
>                  myTotals.last = now; // stop double-reporting
>              }
> @@ -239,7 +238,7 @@ public class Summariser extends Abstract
>       * @param string
>       * @return the sunnary information
>       */
> -    private static String format(String name, RunningSample s, String
> type) {
> +    private static String format(String name, SummariserRunningSample s,
> String type) {
>          DecimalFormat dfDouble = new DecimalFormat("#0.0"); // $NON-NLS-1$
>          StringBuilder tmp = new StringBuilder(20); // for intermediate use
>          StringBuilder sb = new StringBuilder(100); // output line buffer
> @@ -369,6 +368,7 @@ public class Summariser extends Abstract
>              String str;
>              String name = entry.getKey();
>              Totals total = entry.getValue();
> +            total.delta.setEndTime(); // ensure delta has correct end time
>              // Only print final delta if there were some samples in the
> delta
>              // and there has been at least one sample reported previously
>              if (total.delta.getNumSamples() > 0 &&
> total.total.getNumSamples() >  0) {
> @@ -380,7 +380,7 @@ public class Summariser extends Abstract
>                      System.out.println(str);
>                  }
>              }
> -            total.moveDelta();
> +            total.moveDelta(); // This will update the total endTime
>              str = format(name, total.total, "=");
>              if (TOLOG) {
>                  log.info(str);
>
> Added:
> jmeter/trunk/src/core/org/apache/jmeter/reporters/SummariserRunningSample.java
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/reporters/SummariserRunningSample.java?rev=1648146&view=auto
>
> ==============================================================================
> ---
> jmeter/trunk/src/core/org/apache/jmeter/reporters/SummariserRunningSample.java
> (added)
> +++
> jmeter/trunk/src/core/org/apache/jmeter/reporters/SummariserRunningSample.java
> Sun Dec 28 02:55:22 2014
> @@ -0,0 +1,202 @@
> +package org.apache.jmeter.reporters;
> +
> +import java.text.DecimalFormat;
> +
> +import org.apache.jmeter.samplers.SampleResult;
> +
> +class SummariserRunningSample {
> +
> +    private final DecimalFormat errorFormatter = new
> DecimalFormat("#0.00%"); // $NON-NLS-1$
> +
> +    private long counter;
> +
> +    private long runningSum;
> +
> +    private long max;
> +
> +    private long min;
> +
> +    private long errorCount;
> +
> +    private long startTime;
> +
> +    private long endTime;
> +
> +    private final String label;
> +
> +    private final int index;
> +
> +    public SummariserRunningSample(String label, int index) {
> +        this.label = label;
> +        this.index = index;
> +        init();
> +    }
> +
> +    /**
> +     * Copy constructor
> +     * @param src the instance to copy
> +     */
> +    public SummariserRunningSample(SummariserRunningSample src) {
> +        label = src.label;
> +        index = src.index;
> +        counter = src.counter;
> +        errorCount = src.errorCount;
> +        startTime = src.startTime;
> +        endTime = src.endTime;
> +        max = src.max;
> +        min = src.min;
> +        runningSum = src.runningSum;
> +    }
> +
> +    private void init() {
> +        counter = 0L;
> +        runningSum = 0L;
> +        max = Long.MIN_VALUE;
> +        min = Long.MAX_VALUE;
> +        errorCount = 0L;
> +        startTime = System.currentTimeMillis();
> +        endTime = startTime;
> +    }
> +
> +    public void clear() {
> +        init();
> +    }
> +
> +    public void addSample(SummariserRunningSample rs) {
> +        counter += rs.counter;
> +        errorCount += rs.errorCount;
> +        runningSum += rs.runningSum;
> +        if (max < rs.max) {
> +            max = rs.max;
> +        }
> +        if (min > rs.min) {
> +            min = rs.min;
> +        }
> +        // We want end time to be current time so sample rates reflect
> real time
> +        endTime = System.currentTimeMillis();
> +    }
> +
> +    public void addSample(SampleResult res) {
> +        counter += res.getSampleCount();
> +        errorCount += res.getErrorCount();
> +        long aTimeInMillis = res.getTime();
> +        runningSum += aTimeInMillis;
> +        if (aTimeInMillis > max) {
> +            max = aTimeInMillis;
> +        }
> +        if (aTimeInMillis < min) {
> +            min = aTimeInMillis;
> +        }
> +        // We want end time to be current time so sample rates reflect
> real time
> +        endTime = System.currentTimeMillis();
> +    }
> +
> +    /**
> +     * Returns the number of samples that have been recorded by this
> instance of
> +     * the RunningSample class.
> +     *
> +     * @return the number of samples that have been recorded by this
> instance of
> +     *         the RunningSample class.
> +     */
> +    public long getNumSamples() {
> +        return counter;
> +    }
> +
> +    /**
> +     * Get the elapsed time for the samples
> +     *
> +     * @return how long the samples took
> +     */
> +    public long getElapsed() {
> +        if (counter == 0) {
> +            return 0;// No samples collected ...
> +        }
> +        return endTime - startTime;
> +    }
> +
> +    /**
> +     * Returns the throughput associated to this sampler in requests per
> second.
> +     */
> +    public double getRate() {
> +        if (counter == 0) {
> +            return 0.0;// No samples collected ...
> +        }
> +
> +        long howLongRunning = endTime - startTime;
> +
> +        if (howLongRunning == 0) {
> +            return Double.MAX_VALUE;
> +        }
> +
> +        return (double) counter / howLongRunning * 1000.0;
> +    }
> +
> +    /**
> +     * Returns the average time in milliseconds that samples ran in.
> +     *
> +     * @return the average time in milliseconds that samples ran in.
> +     */
> +    public long getAverage() {
> +        if (counter == 0) {
> +            return 0;
> +        }
> +        return runningSum / counter;
> +    }
> +
> +    /**
> +     * @return errorCount
> +     */
> +    public long getErrorCount() {
> +        return errorCount;
> +    }
> +
> +    /**
> +     * Returns a String which represents the percentage of sample errors
> that
> +     * have occurred. ("0.00%" through "100.00%")
> +     *
> +     * @return a String which represents the percentage of sample errors
> that
> +     *         have occurred.
> +     */
> +    public String getErrorPercentageString() {
> +        return errorFormatter.format(getErrorPercentage());
> +    }
> +
> +    /**
> +     * Returns the raw double value of the percentage of samples with
> errors
> +     * that were recorded. (Between 0.0 and 1.0) If you want a nicer
> return
> +     * format, see {@link #getErrorPercentageString()}.
> +     *
> +     * @return the raw double value of the percentage of samples with
> errors
> +     *         that were recorded. Returns 0.0 if there are no samples
> +     */
> +    public double getErrorPercentage() {
> +        if (counter == 0) {
> +            return 0.0;
> +        }
> +        double rval = (double) errorCount / (double) counter;
> +        return rval;
> +    }
> +
> +    /**
> +     * Returns the time in milliseconds of the slowest sample.
> +     *
> +     * @return the time in milliseconds of the slowest sample.
> +     */
> +    public long getMax() {
> +        return max;
> +    }
> +
> +    /**
> +     * Returns the time in milliseconds of the quickest sample.
> +     *
> +     * @return the time in milliseconds of the quickest sample.
> +     */
> +    public long getMin() {
> +        return min;
> +    }
> +
> +    public void setEndTime() {
> +        endTime = System.currentTimeMillis();
> +    }
> +
> +}
>
> Modified: jmeter/trunk/xdocs/changes.xml
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1648146&r1=1648145&r2=1648146&view=diff
>
> ==============================================================================
> --- jmeter/trunk/xdocs/changes.xml (original)
> +++ jmeter/trunk/xdocs/changes.xml Sun Dec 28 02:55:22 2014
> @@ -154,6 +154,7 @@ See  <bugzilla>56357</bugzilla> for deta
>  <h3>Listeners</h3>
>  <ul>
>  <li><bug>57262</bug>Aggregate Report, Aggregate Graph and Summary
Report
> export : headers use keys instead of labels</li>
> +<li><bug>57346</bug>Summariser : The + (difference) reports show wrong
> elapsed time and throughput</li>
>  </ul>
>
>  <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message