How to print percentile using xsl

烈酒焚心 提交于 2019-12-23 22:27:42

问题


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:


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.



来源:https://stackoverflow.com/questions/41819379/how-to-print-percentile-using-xsl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!