Sum of average response times from jmeter in xslt

LinuxBoy

New Member
I've been running a series of webservice tests using Jmeter. I'm outputting the results as an html report using a modified jmeter-results-detail-report_21.xsl stylesheet. Here is an example of one of the reports.What is would like to do is take the sum of all the values in that Average Time column, and place the results in that Total Average Load box I added. Here is part of my xslt which contains the average times I'd like to sum. **...**<xsl:template name="pagelist"><h2>Pages</h2><table class="details" border="0" cellpadding="5" cellspacing="2" width="95%"> <tr valign="top"> <th>URL</th> <th>Tests</th> <th>Failures</th> <th>Success Rate</th> <th>Average Time</th> <th>Min Time</th> <th>Max Time</th> <th></th> </tr> <xsl:for-each select="/testResults/*[not(@lb = preceding::*/@lb)]"> <xsl:variable name="label" select="@lb" /> <xsl:variable name="count" select="count(../*[@lb = current()/@lb])" /> <xsl:variable name="failureCount" select="count(../*[@lb = current()/@lb][attribute::s='false'])" /> <xsl:variable name="successCount" select="count(../*[@lb = current()/@lb][attribute::s='true'])" /> <xsl:variable name="successPercent" select="$successCount div $count" /> <xsl:variable name="totalTime" select="sum(../*[@lb = current()/@lb]/@t)" /> <xsl:variable name="averageTime" select="$totalTime div $count" /> <xsl:variable name="minTime"> <xsl:call-template name="min"> <xsl:with-param name="nodes" select="../*[@lb = current()/@lb]/@t" /> </xsl:call-template> </xsl:variable> <xsl:variable name="maxTime"> <xsl:call-template name="max"> <xsl:with-param name="nodes" select="../*[@lb = current()/@lb]/@t" /> </xsl:call-template> </xsl:variable> <tr valign="top"> <xsl:attribute name="class"> <xsl:choose> <xsl:when test="$failureCount > 0">Failure</xsl:when> </xsl:choose> </xsl:attribute> <td> <xsl:if test="$failureCount > 0"> <a><xsl:attribute name="href">#<xsl:value-of select="$label" /></xsl:attribute> <xsl:value-of select="$label" /> </a> </xsl:if> <xsl:if test="0 >= $failureCount"> <xsl:value-of select="$label" /> </xsl:if> </td> <td> <xsl:value-of select="$count" /> </td> <td> <xsl:value-of select="$failureCount" /> </td> <td> <xsl:call-template name="display-percent"> <xsl:with-param name="value" select="$successPercent" /> </xsl:call-template> </td> <td> <xsl:call-template name="display-time"> <xsl:with-param name="value" select="$averageTime" /> </xsl:call-template> </td> <td> <xsl:call-template name="display-time"> <xsl:with-param name="value" select="$minTime" /> </xsl:call-template> </td> <td> <xsl:call-template name="display-time"> <xsl:with-param name="value" select="$maxTime" /> </xsl:call-template> </td>Here is the part of the xslt where I'd be displaying the value (where it says Total Average Load Time Here). **...** <xsl:template name="summary"> <h2>Summary</h2> <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%"> <tr valign="top"> <th>Tests</th> <th>Failures</th> <th>Success Rate</th> <th>Average Time</th> <th>Min Time</th> <th>Max Time</th> <th>Initial Average Load</th> <th>Total Average Load</th> </tr> <tr valign="top"> <xsl:variable name="allCount" select="count(/testResults/*)" /> <xsl:variable name="allFailureCount" select="count(/testResults/*[attribute::s='false'])" /> <xsl:variable name="allSuccessCount" select="count(/testResults/*[attribute::s='true'])" /> <xsl:variable name="allSuccessPercent" select="$allSuccessCount div $allCount" /> <xsl:variable name="allTotalTime" select="sum(/testResults/*/@t)" /> <xsl:variable name="allAverageTime" select="$allTotalTime div $allCount" /> <xsl:variable name="allMinTime"> <xsl:call-template name="min"> <xsl:with-param name="nodes" select="/testResults/*/@t" /> </xsl:call-template> </xsl:variable> <xsl:variable name="allMaxTime"> <xsl:call-template name="max"> <xsl:with-param name="nodes" select="/testResults/*/@t" /> </xsl:call-template> </xsl:variable> <xsl:attribute name="class"> <xsl:choose> <xsl:when test="$allFailureCount > 0">Failure</xsl:when> </xsl:choose> </xsl:attribute> <td> <xsl:value-of select="$allCount" /> </td> <td> <xsl:value-of select="$allFailureCount" /> </td> <td> <xsl:call-template name="display-percent"> <xsl:with-param name="value" select="$allSuccessPercent" /> </xsl:call-template> </td> <td> <xsl:call-template name="display-time"> <xsl:with-param name="value" select="$allAverageTime" /> </xsl:call-template> </td> <td> <xsl:call-template name="display-time"> <xsl:with-param name="value" select="$allMinTime" /> </xsl:call-template> </td> <td> <xsl:call-template name="display-time"> <xsl:with-param name="value" select="$allMaxTime" /> </xsl:call-template> </td> <td> Initial Average Load Time Here </td> <td> Total Average Load Time Here </td> </tr> </table></xsl:template>Almost forgot, here is what my xml looks like containing the response times that get averaged and then I need summed. (This is just from one iteration however). <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="http://stackoverflow.com/questions/style/jmeter-results-detail-report_21.xsl"?><testResults version="1.2"><httpSample t="78" lt="78" ts="1338394029194" s="true" lb="html" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="4418" ng="1" na="1"/><httpSample t="0" lt="0" ts="1338394029288" s="true" lb="userRoleRetriever" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="758" ng="1" na="1"/><httpSample t="15" lt="15" ts="1338394029288" s="true" lb="UserActivityWSDL" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="2398" ng="1" na="1"/><httpSample t="47" lt="16" ts="1338394029303" s="true" lb="SubscriberMgmtWSDL" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="56434" ng="1" na="1"/><httpSample t="16" lt="0" ts="1338394029350" s="true" lb="NetworkMgmtWSDL" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="33020" ng="1" na="1"/><httpSample t="16" lt="16" ts="1338394029366" s="true" lb="AlarmMgmtWSDL" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="11594" ng="1" na="1"/><httpSample t="1047" lt="1047" ts="1338394029397" s="true" lb="getSubscribers" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="397" ng="1" na="1"/><httpSample t="5000" lt="4969" ts="1338394030460" s="true" lb="getMpegResultsById" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="631459" ng="1" na="1"/><httpSample t="31" lt="31" ts="1338394035491" s="true" lb="getOverallSummary" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="400" ng="1" na="1"/><httpSample t="63" lt="63" ts="1338394035522" s="true" lb="getNeighbourhoodArchiveByNodeId" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="39659" ng="1" na="1"/><httpSample t="15" lt="15" ts="1338394035585" s="true" lb="getOverallSummaryArchive" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="41789" ng="1" na="1"/><httpSample t="47" lt="47" ts="1338394035616" s="true" lb="getAuditValuesById" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="2965" ng="1" na="1"/><httpSample t="15" lt="15" ts="1338394035679" s="true" lb="getNeighbourhoodSummaryByNodeId" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="424" ng="1" na="1"/><httpSample t="15" lt="15" ts="1338394035710" s="true" lb="getNeighbourhoodArchiveByNodeId2" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="39659" ng="1" na="1"/><httpSample t="32" lt="16" ts="1338394035725" s="true" lb="getOverallSummaryArchive2" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="41789" ng="1" na="1"/><httpSample t="15" lt="15" ts="1338394035757" s="true" lb="logUserActivity1" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="222" ng="1" na="1"/><httpSample t="125" lt="125" ts="1338394035772" s="true" lb="getResourceValuesById" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="3094" ng="1" na="1"/><httpSample t="32" lt="32" ts="1338394035897" s="true" lb="getNeighbourhoodSummaryByNodeId2" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="424" ng="1" na="1"/><httpSample t="15" lt="15" ts="1338394035929" s="true" lb="getOverallSummaryArchive3" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="41789" ng="1" na="1"/><httpSample t="31" lt="31" ts="1338394035944" s="true" lb="getNeighbourhoodArchiveByNodeId3" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="39659" ng="1" na="1"/><httpSample t="16" lt="16" ts="1338394035975" s="true" lb="getNeighbourhoodSummaryByNodeId3" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="424" ng="1" na="1"/><httpSample t="438" lt="438" ts="1338394038991" s="true" lb="getDeviceDetailsByNodeId" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="207628" ng="1" na="1"/><httpSample t="32" lt="0" ts="1338394039444" s="true" lb="SubscriberMgmtWSDL2" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="56434" ng="1" na="1"/><httpSample t="15" lt="15" ts="1338394039476" s="true" lb="logUserActivity2" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="222" ng="1" na="1"/><httpSample t="203" lt="203" ts="1338394042491" s="true" lb="getDeviceUpdateByNodeId" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="926" ng="1" na="1"/><httpSample t="16" lt="16" ts="1338394042694" s="true" lb="logUserActivity3" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="222" ng="1" na="1"/><httpSample t="359" lt="344" ts="1338394042710" s="true" lb="getDeviceDetailsByNodeId2" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="207867" ng="1" na="1"/><httpSample t="157" lt="157" ts="1338394043069" s="true" lb="getLatestMpegResultsById" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="16226" ng="1" na="1"/><httpSample t="15" lt="15" ts="1338394043226" s="true" lb="getOverallSummaryArchive4" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="41789" ng="1" na="1"/><httpSample t="31" lt="31" ts="1338394043257" s="true" lb="getNeighbourhoodArchiveByNodeId4" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="39659" ng="1" na="1"/><httpSample t="188" lt="188" ts="1338394043288" s="true" lb="getLatestAuditValueById" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="2975" ng="1" na="1"/><httpSample t="31" lt="31" ts="1338394043476" s="true" lb="getNeighbourhoodSummaryByNodeId4" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="423" ng="1" na="1"/><httpSample t="78" lt="78" ts="1338394043507" s="true" lb="getLatestResourceValueById" rc="200" rm="OK" tn="vuserver 1-1" dt="text" by="2820" ng="1" na="1"/>Any ideas how I could go about this? Help would be greatly appreciated. Thanks!
 
Back
Top