# jmeter-user mailing list archives

##### Site index · List index
Message view
Top
Subject Re: Again about 90% line calculations
Date Thu, 07 Aug 2008 07:21:25 GMT
```Hi,

I looked into the code, and it seems that that graphs class is
org.apache.jmeter.visualizers.DistributionGraph.

It seems that in the end the 90% value is calculated by calling the
getPercentPoint(0.90) method of an instance of
org.apache.jorphan.math.StatCalculator class:

/**
* This class serves as a way to calculate the median of a list of values. It is
*/
public class StatCalculator implements Serializable {
List values = new ArrayList();

................

count++;
double currentVal = val.doubleValue();
sum += currentVal;
sumOfSquares += currentVal * currentVal;
mean = sum / count;
deviation = Math.sqrt((sumOfSquares / count) - (mean * mean));
}

/**
* @param val
*/
int index = Collections.binarySearch(values, val);
if (index >= 0 && index < values.size()) {
} else if (index == values.size() || values.size() == 0) {
} else {
values.add((index * (-1)) - 1, val);
}
}
..................

/**
* Get the value which %percent% of the values are less than. This works
* just like median (where median represents the 50% point). A typical
* desire is to see the 90% point - the value that 90% of the data points
* are below, the remaining 10% are above.
*
* @param percent
* @return number of values less than the percentage
*/
public Number getPercentPoint(float percent) {
if (count > 0) {
return (Number) values.get((int) (values.size() * percent));
}
return new Long(0);
}

.................

Long story short, the values passed to this class instance are cast to
Number and stored in the List sorted by their values.

If we have a List of N values, their indexes will be 0, 1 .... (N-1).

When the getPercentPoint(0.90) is called, float value (N * 0.9) is
cast to integer M so that "the fractional part of the floating point
number is truncated (not rounded)", and the element with index M is
returned.

For example, for a List with 155 values (indexed as 0, 1 ... 154)
float 155*0.9=139.5 cast to int will give us 139, and the value with
index 139 will be returned as "90%" value.

Regards,
Andrey

On Thu, Aug 7, 2008 at 1:24 AM, Oliver Erlewein (DSLWN)
<Oliver.Erlewein@datacom.co.nz> wrote:
> Hi,
>
> Some say that it is [0.9*len(values)]+1. I think the difference is probably not that
critical. What would be good to know is how JMeter itself arrives at the value.
>
> A good text on the subject's on Wikipedia. (http://en.wikipedia.org/wiki/Percentile)
>
> Regards
> Oliver
>
> -----Original Message-----
> From: Ronan Klyne [mailto:ronan.klyne@groupbc.com]
> Sent: Thursday, 7 August 2008 2:50 a.m.
> To: JMeter Users List
> Subject: Re: Again about 90% line calculations
>
> Andrew Melnyk wrote:
>> Hi gentleman,
>>
>> There were a lot of discussion about the meaning of 90% line property of
>> Aggregate graph.
>> I would like to know the exact formula which used to count this value.
>
> You get your values sorted in an array (called, say, 'values').
>
> The 90th percentile is then values[0.9*len(values)]
>
>
>        # r
>
> --
> Ronan Klyne
> Tel: +44 01189 028518
> ronan.klyne@groupbc.com
> www.groupbc.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

--
diem perdidi

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org