jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Coret Bob" <>
Subject Addition to XSLT: percentiles
Date Fri, 10 Sep 2004 13:56:07 GMT
I'd like to share a piece of XSLT with you all. In the distributed report XSLT you have the
minimum, maximum and average response times. I always like percentiles in my reports, mainly
because performance requirements usually state something like "90% of the pages have to be
loaded with 3 seconds". The 90th percentile is the smallest number that is greater than 90%
of the numbers in a given set.

So just as you have the minTime and maxTime variables in the pagelist template you can add
the followng variable for the 90th percentile:

<xsl:variable name="thisPercentile">
  <xsl:call-template name="percentiles">
    <xsl:with-param name="responsetimes" select="../sampleResult[@label = current()/@label]/@time"
    <xsl:with-param name="percentile" select="0.9" />

This is the percentiles "function" which does the math:

<xsl:template name="percentiles">
  <xsl:param name="responsetimes" select="/.." />
  <xsl:param name="percentile" select="." />
  <xsl:variable name="sortedresponsetimes">
    <xsl:for-each select="$responsetimes">
        <xsl:sort data-type="number"/>
        <xsl:element name="time">
          <xsl:value-of select="."/>
  <xsl:variable name="n" select="count($responsetimes)-1" />
  <xsl:variable name="k" select="floor($percentile*$n)+1" />
  <xsl:variable name="f" select="($percentile*$n+1)-$k" />
  <xsl:variable name="a0" select="$sortedresponsetimes[1]/time[$k]" />
  <xsl:variable name="a1" select="$sortedresponsetimes[1]/time[$k+1]" />
  <xsl:value-of select="$a0+ ( $f *( $a1 - $a0))" />

The method of sorting the responsetimes can use some improvements: it works, but is looks
like a hack...

To get this to work with Saxon you have to specificy version 1.1:

<xsl:stylesheet xmlns:xsl="" version="1.1">

BTW, is there a place where we can share JMeter XSLT's ? I have made a "results to CSV"-XSL
as well, for those interested.

With regards,
Bob Coret

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message