How to print percentile using xsl

2019-07-21 07:06发布

I am trying to generate 99 percentile in the HTML report using jmeter-results-detail-report_21.xsl file. I am able to print the 90 percentile using the below code:

</xsl:template>
<xsl:template name="percentiles">
       <xsl:param name="responsetimes" />
       <xsl:param name="percentile" />
        <xsl:variable name="sortedresponsetimes">
           <xsl:for-each select="$responsetimes">
               <xsl:sort data-type="number"/>
               <xsl:element name="time">
                   <xsl:value-of select="."/>
               </xsl:element>
           </xsl:for-each>
       </xsl:variable>
       <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))" />
</xsl:template>

How to modify the above code to print the 99 percentile along with the 90 percentile

1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-07-21 07:28

What part of the problem is causing you trouble? You have code here that takes the required percentile as a parameter, just supply the value 99 instead of 90 as the parameter value. If you want several percentiles in the same run, then factor out the code that does the sorting into a calling routine so the sort only gets done once.

查看更多
登录 后发表回答