jmeter+ant+jenkins+mac报告优化(二):添加90% Line和QPS
一、优化内容
1、Summary中只标红Failures数
2、Pages页面按Average Time倒序排序
3、Average Time超过2s标黄显示
4、Pagelist 模块中针对错误和超长时间接口标色显示
5、添加90% Line和QPS
6、Failure Detail模块显示Response Data
效果:

二、具体实现
1、 Summary中的只标红Failures数:
屏蔽Summary中class属性
<!--
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$allFailureCount > 0">Failure</xsl:when>
</xsl:choose>
</xsl:attribute>
-->修改allFailureCount
<td align="center">
<xsl:value-of select="$allSuccessCount" />
</td>
<xsl:choose>
<xsl:when test="$allFailureCount > 0">
<td align="center" style="font-weight:bold">
<font color="red">
<xsl:value-of select="$allFailureCount" />
</font>
</td>
</xsl:when>
<xsl:otherwise>
<td align="center">
<xsl:value-of select="$allFailureCount" />
</td>
</xsl:otherwise>
</xsl:choose>
2、Pages页面按Average Time倒序排序:
在Pagelist模板中for-each下添加
<xsl:for-each select="/testResults/*[not(@lb = preceding::*/@lb)]" >
<!-- 按平均时间排序 -->
<xsl:sort select="sum(../*[@lb = current()/@lb]/@t) div count(../*[@lb = current()/@lb])" data-type="number" order="descending"/>
3、接口Average Time超过2s标黄显示:
- 添加LongTime css
.Failure {
font-weight:bold; color:red;
}
.LongTime {
font-weight:bold; color:#ff9900;
}
4、Pagelist 模块中针对错误和超长时间接口标色显示
<tr valign="top">
<xsl:choose>
<!-- 失败用例标红显示 -->
<xsl:when test="$failureCount > 0">
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$failureCount > 0">Failure</xsl:when>
</xsl:choose>
</xsl:attribute>
</xsl:when>
<!-- 平均时间超过2s,标色显示 -->
<xsl:when test="$averageTime > 2000">
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$averageTime > 2000">LongTime</xsl:when>
</xsl:choose>
</xsl:attribute>
</xsl:when>
</xsl:choose>
5、添加90% Line和QPS
- 添加90 %lineTime模板
<xsl:template name="max">
<xsl:param name="nodes" select="/.." />
<xsl:choose>
<xsl:when test="not($nodes)">NaN</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$nodes">
<xsl:sort data-type="number" order="descending" />
<xsl:if test="position() = 1">
<xsl:value-of select="number(.)" />
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template> <!-- 90% line time -->
<xsl:template name="lineTime">
<xsl:param name="nodes" select="/.." />
<xsl:choose>
<xsl:when test="not($nodes)">NaN</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$nodes">
<xsl:sort data-type="number" />
<!-- last() 返回当前上下文中的最后一个节点位置数 -->
<!-- ceiling(number) 返回大于number的最小整数 -->
<!-- floor(number) 返回不大于number的最大整数 -->
<!-- position() 返回当前节点位置的数字 -->
<!-- number(object) 使对象转换成数字 -->
<xsl:choose>
<!-- 当只有一个节点时,向上取整 -->
<xsl:when test="last() = 1">
<xsl:if test="position() = ceiling(last()*0.9)">
<xsl:value-of select="number(.)" />
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:if test="position() = floor(last()*0.9)">
<xsl:value-of select="number(.)" />
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
- Sunmary中添加标题
<tr valign="top">
<th># Samples</th>
<th>Success</th>
<th>Failures</th>
<th>Success Rate</th>
<th>Average Time</th>
<th>Min Time</th>
<th>Max Time</th>
<th>90% Line</th>
<th>QPS</th>
</tr>
- Summary中添加allLineTime和qps变量
<xsl:variable name="allMaxTime">
<xsl:call-template name="max">
<xsl:with-param name="nodes" select="/testResults/*/@t" />
</xsl:call-template>
</xsl:variable>
<!-- New add 90% line -->
<xsl:variable name="allLineTime">
<xsl:call-template name="lineTime">
<xsl:with-param name="nodes" select="/testResults/*/@t" />
</xsl:call-template>
</xsl:variable>
<!-- 将毫秒转换成秒 -->
<xsl:variable name="qps" select="$allCount * 1000 div $allTotalTime"/>
- Summary中调用allLineTime和qps变量
<td align="center">
<xsl:call-template name="display-time">
<xsl:with-param name="value" select="$allMaxTime" />
</xsl:call-template>
</td>
<td align="center">
<xsl:call-template name="display-time">
<xsl:with-param name="value" select="$allLineTime" />
</xsl:call-template>
</td>
<td align="center">
<xsl:call-template name="display-qps">
<xsl:with-param name="value" select="$qps" />
</xsl:call-template>
- pagelist中添加标题
<xsl:template name="pagelist">
<h2>Pages</h2>
<table align="center" class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<tr valign="top">
<th>URL</th>
<th># Samples</th>
<th>Success</th>
<th>Failures</th>
<th>Success Rate</th>
<th>Average Time</th>
<th>Min Time</th>
<th>Max Time</th>
<th>90% Line</th>
<th>QPS</th>
<th></th>
</tr>
- pagelist中添加allLineTime和qps变量
<xsl:variable name="maxTime">
<xsl:call-template name="max">
<xsl:with-param name="nodes" select="../*[@lb = current()/@lb]/@t" />
</xsl:call-template>
</xsl:variable>
<!-- new add 90% line time -->
<xsl:variable name="nintyTime">
<xsl:call-template name="lineTime">
<xsl:with-param name="nodes" select="../*[@lb = current()/@lb]/@t" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="qpsTime" select="$count * 1000 div $totalTime"/>
- pagelist中调用allLineTime和qps变量
<td align="center">
<xsl:call-template name="display-time">
<xsl:with-param name="value" select="$maxTime" />
</xsl:call-template>
</td>
<!-- Page页面添加90% LineTime -->
<td align="center">
<xsl:call-template name="display-time">
<xsl:with-param name="value" select="$nintyTime" />
</xsl:call-template>
</td>
<td align="center">
<xsl:call-template name="display-qps">
<xsl:with-param name="value" select="$qpsTime" />
</xsl:call-template>
</td>
6、Failure Detail模块显示Response Data
- 设置showData为‘y’
<!-- Defined parameters (overrideable) -->
<xsl:param name="showData" select="'y'"/>
<xsl:param name="titleReport" select="'Interface Test Results'"/>
<xsl:param name="dateReport" select="'date not defined'"/>
- 替换内容
<table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<tr valign="top">
<th align="center">Response</th>
<th align="center">Failure Message</th>
<xsl:if test="$showData = 'y'">
<th align="left">Response Data</th>
</xsl:if>
</tr> <xsl:for-each select="/testResults/*[@lb = current()/@lb][attribute::s='false']">
<tr>
<td><xsl:value-of select="@rc | @rs" /> - <xsl:value-of select="@rm" /></td>
<td><xsl:value-of select="assertionResult/failureMessage" /></td>
<xsl:if test="$showData = 'y'">
<td><xsl:value-of select="responseData" /></td>
</xsl:if>
</tr>
</xsl:for-each>
7.添加Host
<xsl:template name="pageHeader">
<h1><xsl:value-of select="$titleReport" /></h1>
<table width="100%">
<tr>
<!-- 获取requestHeader数据 -->
<xsl:variable name="URL" select="/testResults/httpSample/requestHeader" />
<!-- 从获取的URL中截取数据,第二代表起始位置,第三位代表长度 -->
<xsl:variable name="newURL" select="substring($URL, 94, 40)" />
<!-- 已换行符来截取,before代表换行符之前的数据 -->
<xsl:variable name="remaining" select="substring-before($newURL, ' ')" />
<td align="left">Date report: <xsl:value-of select="$dateReport" /></td>
<td align="center">Host: <xsl:value-of select="$remaining" /></td>
<td align="right"><a href="./TestLog.html">测试日志</a></td>
</tr>
</table>
jmeter+ant+jenkins+mac报告优化(二):添加90% Line和QPS的更多相关文章
- jmeter+ant+jenkins+mac报告优化
一.在上篇博客中生成的报告有两个问题: 1.date not defined 2.Min Time和Max Time显示成了NaN 二.Jmeter+Ant报告生成原理: 在解决问题之前,让我们先弄清 ...
- jmeter+ant+jenkins+mac报告优化(一):解决Min Time和Max Time显示NaN
一.在上篇博客中生成的报告有两个问题: 1.date not defined 2.Min Time和Max Time显示成了NaN 二.Jmeter+Ant报告生成原理: 1.在Jmeter的extr ...
- jmeter+ant+jenkins+mac 报告优化(三) 使用命令行执行jmeter方式生成多维度的图形化HTML报告
1.在构建中填写如下命令: 2.start.sh文件的内容 cd /Applications/apache-jmeter-3.0/bin/ CURTIME=`date +%Y%m%d%H%M` ./j ...
- jmeter+ant+jenkins+mac使用HTML Publisher插件后查看html报告显示不正常
Jenkins安全默认将以下功能关闭: 1.javascript2.html上的内置插件3.内置css或从其它站的css4.从其它站的图处5.AJAX 报告中有javascript,所以显示异常.解决 ...
- jmeter+ant+jenkins+mac环境搭建
一.环境准备 1.JDK环境:http://www.oracle.com/technetwork/java/javase/downloads/index.html 2.ANT环境:http://ant ...
- Jmeter+Ant+Jenkins接口自动化测试(二)_测试方案设计及jmeter脚本开发
前言 根据之前部署好的测试环境,进行接口自动化测试的方案设计及Jmeter脚本开发.测试方案设计过程中采用了数据分离和对象分离等思路,因此直接通过特定的测试用例文档来驱动整个自动化接口测试的执行,相关 ...
- jmeter+ant+jenkins+mac 构建后自动发送邮件
1.安装Email Extension Plugin插件 2.进入系统管理-系统设置,按如下进行设置: ------------------------------------------------ ...
- jmeter+ant+jenkins生产的报告乱码
jmeter+ant+jenkins生产的报告乱码 问题:生产报告会乱码的问题,一般是有编码格式引起的.我遇到的问题是,jmeter需要读取csv的数据作为参数.但是我们并不知道csv保存是什么编码格 ...
- jmeter--接口自动化jmeter+ant+jenkins
的 一.介绍 接口自动化工具:jmeter+ant+jenkins 流程: -1.jmeter已录制或手动设置好脚本后 -2.配置ant,使用Ant工具,进行批量执行jmeter的脚本 -3.使用Je ...
随机推荐
- NotePad++替换行前、行后空格,替换空行
用 Notepad++ 打开,把每一个将要放在表中单元格的内容放一行(注: ^ 代表行首 $ 代表行尾) 去除行尾空格和空白行:按CTRL+H 选择正则表达式– 查找目标:\s+$ 替换为空 去除行首 ...
- 关于进程exit后,内存释放释放的实践
最近碰到一个问题,或许也是小猿们都会碰到的问题:内存泄露. 都知道malloc后需要free才能释放内存,shmat后需要shmdt才能断掉内存区并使用IPC_RMID命令删除共享内存.那么如果是当前 ...
- 2015年传智播客JavaEE 第168期就业班视频教程06-权限校验子系统介绍
没整过论坛你也整过淘宝,其实淘宝登录的也分商家和个人,卖家和买家,不同的人登录显示的东西是不一样的.权限系统要分两大过程,第四天上午下午分开,分为授权与校验.我把某一个职务给你叫做授权,例如封你为征西 ...
- Gtk-WARNING **: cannot open display: :0.0之解决
当使用su 到另外一个用户运行某个程序,而这个程序又要有图形显示的时候,就有可能有下面提示: root@dt:~# sudo -i -u keji google-chrome No protocol ...
- react-navigation 3.x版本的安装以及react-native-gesture-handler配置
一.安装依赖,使用npm或yarn命令,3.x版本必须安装react-native-gesture-handler react-navigation react-native-gesture-hand ...
- springboot 配置jsp支持
springboot默认并不支持jsp模板,所以需要配置. 下面是一个可以运行的例子: 首先配置属性文件: spring.http.encoding.force=true spring.http. ...
- SpringMVC学习总结(一)--Hello World入门
一.什么是Spring MVC Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面.Spring 框架提供了构建 Web 应用程序的全功能 ...
- 通过curl模拟多线程抓取网页(curl_multi_*)
curl请求多个url,以前都是使用循环来处理.最近发现可以通过curl_multi_*系列函数来模拟多线程.比对一下,发现如果请求的url只有几个,2种方案耗时差不多,但是url比较多,差距就非常明 ...
- Illegal mix of collations for operation 'like' while searching with Ignited-Datatables
Stack Overflow Questions Developer Jobs Tags Users Log In Sign Up Join Stack Overflow to learn, sh ...
- YUI前端优化原则-cookie与图像
四.图片.Coockie与移动应用篇 除此之外,图片和Coockie也是我们网站中几乎不可缺少组成部分,此外随着移动设备的流行,对于移动应用的优化也十分重要.这主要包括:Coockie: 减小Cook ...