Advertisement
Guest User

Untitled

a guest
Jun 25th, 2012
2,428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.22 KB | None | 0 0
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  3.  
  4. <!--
  5. Licensed to the Apache Software Foundation (ASF) under one or more
  6. contributor license agreements. See the NOTICE file distributed with
  7. this work for additional information regarding copyright ownership.
  8. The ASF licenses this file to You under the Apache License, Version 2.0
  9. (the "License"); you may not use this file except in compliance with
  10. the License. You may obtain a copy of the License at
  11.  
  12. http://www.apache.org/licenses/LICENSE-2.0
  13.  
  14. Unless required by applicable law or agreed to in writing, software
  15. distributed under the License is distributed on an "AS IS" BASIS,
  16. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. See the License for the specific language governing permissions and
  18. limitations under the License.
  19. -->
  20.  
  21. <!--
  22. Stylesheet for processing 2.1 output format test result files
  23. To uses this directly in a browser, add the following to the JTL file as line 2:
  24. <?xml-stylesheet type="text/xsl" href="../extras/jmeter-results-detail-report_21.xsl"?>
  25. and you can then view the JTL in a browser
  26. -->
  27.  
  28. <xsl:output method="html" indent="yes" encoding="US-ASCII" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" />
  29.  
  30. <!-- Defined parameters (overrideable) -->
  31. <xsl:param name="showData" select="'n'"/>
  32.  
  33. <xsl:template match="testResults">
  34. <html>
  35. <head>
  36. <title>Load Test Results</title>
  37. <style type="text/css">
  38. body {
  39. font:normal 68% verdana,arial,helvetica;
  40. color:#000000;
  41. }
  42. table tr td, table tr th {
  43. font-size: 68%;
  44. }
  45. table.details tr th{
  46. font-weight: bold;
  47. text-align:left;
  48. background:#a6caf0;
  49. white-space: nowrap;
  50. }
  51. table.details tr td{
  52. background:#eeeee0;
  53. white-space: nowrap;
  54. }
  55. h1 {
  56. margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
  57. }
  58. h2 {
  59. margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
  60. }
  61. h3 {
  62. margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
  63. }
  64. .Failure {
  65. font-weight:bold; color:red;
  66. }
  67.  
  68.  
  69. img
  70. {
  71. border-width: 0px;
  72. }
  73.  
  74. .expand_link
  75. {
  76. position=absolute;
  77. right: 0px;
  78. width: 27px;
  79. top: 1px;
  80. height: 27px;
  81. }
  82.  
  83. .page_details
  84. {
  85. display: none;
  86. }
  87.  
  88. .page_details_expanded
  89. {
  90. display: block;
  91. display/* hide this definition from IE5/6 */: table-row;
  92. }
  93.  
  94.  
  95. </style>
  96. <script language="JavaScript"><![CDATA[
  97. function expand(details_id)
  98. {
  99.  
  100. document.getElementById(details_id).className = "page_details_expanded";
  101. }
  102.  
  103. function collapse(details_id)
  104. {
  105.  
  106. document.getElementById(details_id).className = "page_details";
  107. }
  108.  
  109. function change(details_id)
  110. {
  111. if(document.getElementById(details_id+"_image").src.match("expand"))
  112. {
  113. document.getElementById(details_id+"_image").src = "collapse.jpg";
  114. expand(details_id);
  115. }
  116. else
  117. {
  118. document.getElementById(details_id+"_image").src = "expand.jpg";
  119. collapse(details_id);
  120. }
  121. }
  122. ]]></script>
  123. </head>
  124. <body>
  125.  
  126. <xsl:call-template name="pageHeader" />
  127.  
  128. <xsl:call-template name="summary" />
  129. <hr size="1" width="95%" align="left" />
  130.  
  131. <xsl:call-template name="pagelist" />
  132. <hr size="1" width="95%" align="left" />
  133.  
  134. <xsl:call-template name="detail" />
  135.  
  136. </body>
  137. </html>
  138. </xsl:template>
  139.  
  140. <xsl:template name="pageHeader">
  141. <h1>Load Test Results</h1>
  142. <table width="100%">
  143. <tr>
  144. <td align="left"></td>
  145. <td align="right">Designed for use with <a href="http://jakarta.apache.org/jmeter">JMeter</a> and <a href="http://ant.apache.org">Ant</a>.</td>
  146. </tr>
  147. </table>
  148. <hr size="1" />
  149. </xsl:template>
  150.  
  151. <xsl:template name="summary">
  152. <h2>Summary</h2>
  153. <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
  154. <tr valign="top">
  155. <th>Tests</th>
  156. <th>Failures</th>
  157. <th>Success Rate</th>
  158. <th>Average Time</th>
  159. <th>Min Time</th>
  160. <th>Max Time</th>
  161. </tr>
  162. <tr valign="top">
  163. <xsl:variable name="allCount" select="count(/testResults/*)" />
  164. <xsl:variable name="allFailureCount" select="count(/testResults/*[attribute::s='false'])" />
  165. <xsl:variable name="allSuccessCount" select="count(/testResults/*[attribute::s='true'])" />
  166. <xsl:variable name="allSuccessPercent" select="$allSuccessCount div $allCount" />
  167. <xsl:variable name="allTotalTime" select="sum(/testResults/*/@t)" />
  168. <xsl:variable name="allAverageTime" select="$allTotalTime div $allCount" />
  169. <xsl:variable name="allMinTime">
  170. <xsl:call-template name="min">
  171. <xsl:with-param name="nodes" select="/testResults/*/@t" />
  172. </xsl:call-template>
  173. </xsl:variable>
  174. <xsl:variable name="allMaxTime">
  175. <xsl:call-template name="max">
  176. <xsl:with-param name="nodes" select="/testResults/*/@t" />
  177. </xsl:call-template>
  178. </xsl:variable>
  179. <xsl:attribute name="class">
  180. <xsl:choose>
  181. <xsl:when test="$allFailureCount &gt; 0">Failure</xsl:when>
  182. </xsl:choose>
  183. </xsl:attribute>
  184. <td>
  185. <xsl:value-of select="$allCount" />
  186. </td>
  187. <td>
  188. <xsl:value-of select="$allFailureCount" />
  189. </td>
  190. <td>
  191. <xsl:call-template name="display-percent">
  192. <xsl:with-param name="value" select="$allSuccessPercent" />
  193. </xsl:call-template>
  194. </td>
  195. <td>
  196. <xsl:call-template name="display-time">
  197. <xsl:with-param name="value" select="$allAverageTime" />
  198. </xsl:call-template>
  199. </td>
  200. <td>
  201. <xsl:call-template name="display-time">
  202. <xsl:with-param name="value" select="$allMinTime" />
  203. </xsl:call-template>
  204. </td>
  205. <td>
  206. <xsl:call-template name="display-time">
  207. <xsl:with-param name="value" select="$allMaxTime" />
  208. </xsl:call-template>
  209. </td>
  210. </tr>
  211. </table>
  212. </xsl:template>
  213.  
  214. <xsl:template name="pagelist">
  215. <h2>Pages</h2>
  216. <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
  217. <tr valign="top">
  218. <th>URL</th>
  219. <th>Tests</th>
  220. <th>Failures</th>
  221. <th>Success Rate</th>
  222. <th>Average Time</th>
  223. <th>Min Time</th>
  224. <th>Max Time</th>
  225. <th></th>
  226. </tr>
  227. <xsl:for-each select="/testResults/*[not(@lb = preceding::*/@lb)]">
  228. <xsl:variable name="label" select="@lb" />
  229. <xsl:variable name="count" select="count(../*[@lb = current()/@lb])" />
  230. <xsl:variable name="failureCount" select="count(../*[@lb = current()/@lb][attribute::s='false'])" />
  231. <xsl:variable name="successCount" select="count(../*[@lb = current()/@lb][attribute::s='true'])" />
  232. <xsl:variable name="successPercent" select="$successCount div $count" />
  233. <xsl:variable name="totalTime" select="sum(../*[@lb = current()/@lb]/@t)" />
  234. <xsl:variable name="averageTime" select="$totalTime div $count" />
  235. <xsl:variable name="minTime">
  236. <xsl:call-template name="min">
  237. <xsl:with-param name="nodes" select="../*[@lb = current()/@lb]/@t" />
  238. </xsl:call-template>
  239. </xsl:variable>
  240. <xsl:variable name="maxTime">
  241. <xsl:call-template name="max">
  242. <xsl:with-param name="nodes" select="../*[@lb = current()/@lb]/@t" />
  243. </xsl:call-template>
  244. </xsl:variable>
  245. <tr valign="top">
  246. <xsl:attribute name="class">
  247. <xsl:choose>
  248. <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
  249. </xsl:choose>
  250. </xsl:attribute>
  251. <td>
  252. <xsl:if test="$failureCount > 0">
  253. <a><xsl:attribute name="href">#<xsl:value-of select="$label" /></xsl:attribute>
  254. <xsl:value-of select="$label" />
  255. </a>
  256. </xsl:if>
  257. <xsl:if test="0 >= $failureCount">
  258. <xsl:value-of select="$label" />
  259. </xsl:if>
  260. </td>
  261. <td>
  262. <xsl:value-of select="$count" />
  263. </td>
  264. <td>
  265. <xsl:value-of select="$failureCount" />
  266. </td>
  267. <td>
  268. <xsl:call-template name="display-percent">
  269. <xsl:with-param name="value" select="$successPercent" />
  270. </xsl:call-template>
  271. </td>
  272. <td>
  273. <xsl:call-template name="display-time">
  274. <xsl:with-param name="value" select="$averageTime" />
  275. </xsl:call-template>
  276. </td>
  277. <td>
  278. <xsl:call-template name="display-time">
  279. <xsl:with-param name="value" select="$minTime" />
  280. </xsl:call-template>
  281. </td>
  282. <td>
  283. <xsl:call-template name="display-time">
  284. <xsl:with-param name="value" select="$maxTime" />
  285. </xsl:call-template>
  286. </td>
  287. <td align="center">
  288. <a href="">
  289. <xsl:attribute name="href"><xsl:text/>javascript:change('page_details_<xsl:value-of select="position()" />')</xsl:attribute>
  290. <img src="expand.jpg" alt="expand/collapse"><xsl:attribute name="id"><xsl:text/>page_details_<xsl:value-of select="position()" />_image</xsl:attribute></img>
  291. </a>
  292. </td>
  293. </tr>
  294.  
  295. <tr class="page_details">
  296. <xsl:attribute name="id"><xsl:text/>page_details_<xsl:value-of select="position()" /></xsl:attribute>
  297. <td colspan="8" bgcolor="#FF0000">
  298. <div align="center">
  299. <b>Details for Page "<xsl:value-of select="$label" />"</b>
  300. <table bordercolor="#000000" border="1" cellpadding="0" cellspacing="0" width="95%">
  301. <tr>
  302. <th>Thread</th>
  303. <th>Iteration</th>
  304. <th>Time (milliseconds)</th>
  305. <th>Bytes</th>
  306. <th>Success</th>
  307. </tr>
  308.  
  309. <xsl:for-each select="../*[@lb = $label and @tn != $label]">
  310. <tr>
  311. <td><xsl:value-of select="@tn" /></td>
  312. <td><xsl:value-of select="position()" /></td>
  313. <td align="right"><xsl:value-of select="@t" /></td>
  314. <!-- TODO allow for missing bytes field -->
  315. <td align="right"><xsl:value-of select="@by" /></td>
  316. <td align="center"><xsl:value-of select="@s" /></td>
  317. </tr>
  318. </xsl:for-each>
  319.  
  320. </table>
  321. </div>
  322. </td>
  323. </tr>
  324.  
  325. </xsl:for-each>
  326. </table>
  327. </xsl:template>
  328.  
  329. <xsl:template name="detail">
  330. <xsl:variable name="allFailureCount" select="count(/testResults/*[attribute::s='false'])" />
  331.  
  332. <xsl:if test="$allFailureCount > 0">
  333. <h2>Failure Detail</h2>
  334.  
  335. <xsl:for-each select="/testResults/*[not(@lb = preceding::*/@lb)]">
  336.  
  337. <xsl:variable name="failureCount" select="count(../*[@lb = current()/@lb][attribute::s='false'])" />
  338.  
  339. <xsl:if test="$failureCount > 0">
  340. <h3><xsl:value-of select="@lb" /><a><xsl:attribute name="name"><xsl:value-of select="@lb" /></xsl:attribute></a></h3>
  341.  
  342. <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
  343. <tr valign="top">
  344. <th>Response</th>
  345. <th>Failure Message</th>
  346. <th>Request</th>
  347. <th>Response</th>
  348. <th>Sample end time</th>
  349. <xsl:if test="$showData = 'y'">
  350. <th>Response Data</th>
  351. </xsl:if>
  352. </tr>
  353.  
  354. <xsl:for-each select="/testResults/*[@lb = current()/@lb][attribute::s='false']">
  355. <tr>
  356. <td><xsl:value-of select="@rc | @rs" /> - <xsl:value-of select="@rm" /></td>
  357. <td><xsl:value-of select="assertionResult/failureMessage" /></td>
  358. <td width="700"><xsl:value-of select="samplerData" /></td>
  359. <td width="500"><xsl:value-of select="responseData" /></td>
  360. <td><xsl:value-of select="responseHeader" /></td>
  361. <xsl:if test="$showData = 'y'">
  362. <td><xsl:value-of select="./binary" /></td>
  363. </xsl:if>
  364. </tr>
  365. </xsl:for-each>
  366.  
  367. </table>
  368. </xsl:if>
  369.  
  370. </xsl:for-each>
  371. </xsl:if>
  372. </xsl:template>
  373.  
  374. <xsl:template name="min">
  375. <xsl:param name="nodes" select="/.." />
  376. <xsl:choose>
  377. <xsl:when test="not($nodes)">NaN</xsl:when>
  378. <xsl:otherwise>
  379. <xsl:for-each select="$nodes">
  380. <xsl:sort data-type="number" />
  381. <xsl:if test="position() = 1">
  382. <xsl:value-of select="number(.)" />
  383. </xsl:if>
  384. </xsl:for-each>
  385. </xsl:otherwise>
  386. </xsl:choose>
  387. </xsl:template>
  388.  
  389. <xsl:template name="max">
  390. <xsl:param name="nodes" select="/.." />
  391. <xsl:choose>
  392. <xsl:when test="not($nodes)">NaN</xsl:when>
  393. <xsl:otherwise>
  394. <xsl:for-each select="$nodes">
  395. <xsl:sort data-type="number" order="descending" />
  396. <xsl:if test="position() = 1">
  397. <xsl:value-of select="number(.)" />
  398. </xsl:if>
  399. </xsl:for-each>
  400. </xsl:otherwise>
  401. </xsl:choose>
  402. </xsl:template>
  403.  
  404. <xsl:template name="display-percent">
  405. <xsl:param name="value" />
  406. <xsl:value-of select="format-number($value,'0.00%')" />
  407. </xsl:template>
  408.  
  409. <xsl:template name="display-time">
  410. <xsl:param name="value" />
  411. <xsl:value-of select="format-number($value,'0 ms')" />
  412. </xsl:template>
  413.  
  414. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement