﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-qileilove-文章分类-jmeter</title><link>http://www.blogjava.net/qileilove/category/54193.html</link><description>不想做屌丝的码农，不是好项目经理！屌丝生涯从此开始！</description><language>zh-cn</language><lastBuildDate>Tue, 15 Apr 2014 11:53:00 GMT</lastBuildDate><pubDate>Tue, 15 Apr 2014 11:53:00 GMT</pubDate><ttl>60</ttl><item><title>Jmeter的正则表达式未正确提取数据</title><link>http://www.blogjava.net/qileilove/articles/412442.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Tue, 15 Apr 2014 02:58:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/412442.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/412442.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/412442.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/412442.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/412442.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=45365" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/04/14982672_2014041016025213cXv.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　在进行脚本调试时，在Apply-Money-Page中需要Save-base中header的id参数，采用正则表达式提取器获取</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=45366" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/04/14982672_201404101602522yiA7.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　使用正则表达式提取器，结果无法获取到需要的参数</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=45367" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/04/14982672_201404101602523JIeI.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　最后定位是因为【？】是一个正则表达式的字符，被转义了</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=45368" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/04/14982672_201404101602524y6jq.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><img src ="http://www.blogjava.net/qileilove/aggbug/412442.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-04-15 10:58 <a href="http://www.blogjava.net/qileilove/articles/412442.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JMETER测试LDAP服务</title><link>http://www.blogjava.net/qileilove/articles/411494.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Wed, 26 Mar 2014 05:22:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/411494.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/411494.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/411494.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/411494.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/411494.html</trackback:ping><description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;"><strong>&nbsp;建立一个LDAP测试计划</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;">9.1 添加用户</p><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;">创建一个Thread Group用于添加用户和设置请求次数和频率.</p><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;">9.2 添加一个登录控制元素</p><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;">可以添加一个Config Element的Login Config Element用于用户登录控制.</p><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;">9.3 添加一个LDAP Request Defaults</p><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;">可以添加一个config element中的LDAP Request Defaults用于控制一些共享默认值.</p><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;">9.4 添加LDAP Request</p><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;">添加的LDAP Request通过选择不同的测试配置来完成四种操作: 添加,删除,修改和查询.</p><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;">例如, 修改:</p><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;">9.5 添加一个Listener来查看和保存测试结果</p><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;">添加了一个View Results in Table的listener</p><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;">9.6 保存测试用例</p><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: #464646; font-family: simsun; font-size: 14px; background-color: #eaf7fd;">9.7 运行测试用例</p><img src ="http://www.blogjava.net/qileilove/aggbug/411494.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-26 13:22 <a href="http://www.blogjava.net/qileilove/articles/411494.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Jmeter JDBC请求的问题</title><link>http://www.blogjava.net/qileilove/articles/411447.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Tue, 25 Mar 2014 03:31:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/411447.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/411447.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/411447.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/411447.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/411447.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　如何添加一个JDBC请求？本次以Orale为例。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　1 &nbsp;From网上下载一个名为Class12.jar 的驱动包，然后放到该目录下：【否则会提示no suitable driver】</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=44938" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/03/14982672_20140312162830152F1.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">2 &nbsp;查看链接<a target="_self" style="word-break: break-all; color: #202859;"><u style="word-break: break-all;"><strong style="word-break: break-all;">Oracle</strong></u></a>的参数：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　URL：jdbc:oracle:thin:@10.1.1.223:1521:XE &nbsp; &nbsp; &nbsp;其中1521是监听端口 XE 是实例名</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　JDBC Driver class ：oracle.jdbc.driver.OracleDriver</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　3 &nbsp;在<a target="_self" style="word-break: break-all; color: #202859;"><u style="word-break: break-all;"><strong style="word-break: break-all;">Jmeter</strong></u></a>配置元素里新增一个JDBC conn config 并按照下边的格式录入：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=44939" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><font color="#202859"><span style="line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/03/14982672_201403121628302JAHb.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></span></font><br /></a><a href="http://www.51testing.com/batch.download.php?aid=44939" target="_blank"><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><strong style="word-break: break-all; line-height: normal !important;">　4 &nbsp;添加一个JDBC Request &nbsp; 输入相应的sql【注意要去掉分号】</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=44940" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/03/14982672_201403121628303HsHm.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><strong style="word-break: break-all; line-height: normal !important;">　　5 &nbsp;添加一个查看结果树，实行下脚本，检查是否正确</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=44941" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/03/14982672_201403121628304RKzr.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　以上可以看出，链接是成功的。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　这个只是一个最简单的例子了我想，实际根据需要逻辑上还需要考虑，在执行事务之前查询下，是否有数据，删除相应的测试数据，然后再执行事务，执行完数据后，再次删除测试数据。</div></a></div><img src ="http://www.blogjava.net/qileilove/aggbug/411447.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-25 11:31 <a href="http://www.blogjava.net/qileilove/articles/411447.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用JMeter创建FTP测试计划</title><link>http://www.blogjava.net/qileilove/articles/411422.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Mon, 24 Mar 2014 08:55:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/411422.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/411422.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/411422.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/411422.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/411422.html</trackback:ping><description><![CDATA[<p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">FTP服务主要提供上传和下载功能。有时间需要我们测试服务器上传和下载的性能。在这里我通过JMeter做一个FTP测试计划的例子。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">当然，JMeter官方网站的用户手册也有例子，但由于版本较早，我也算是对自己学习的一个总结，所以再整理一个。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">* 本人使用的是JMeter2.4版本。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">* 测试的服务器是IP：124.205.228.54 &nbsp;(由于找不到FTP站点，所以在&#8220;主机屋网站<a href="http://www.zhujiwu.com/" style="color: #1d58d1; text-decoration: none;">http://www.zhujiwu.com</a>申请了一个免费的FTP空间&#8221;)</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">1.创建一个线程组</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011070116291613.jpg" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">2.线程组---&gt;添加---&gt;配置元件---&gt;FTP请求缺省值。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011070116330173.jpg" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">3.线程组---&gt;添加---&gt;Sampler---&gt;FTP请求</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011070116361794.jpg" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">说明：</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">IP &nbsp; &nbsp;为你FTP服务的IP</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">Remote file 为你FTP服务器上的一个文件。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">local file &nbsp;为本地你存放到本机上的路径。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">选择 &nbsp; get(RETR) &nbsp;为下载方式。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">填写你的FTP服务器的用户名密码。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">3.按照第二步的方式再添加一个&#8220;FTP请求&#8221;。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011070116453582.jpg" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">说明：</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">IP &nbsp; &nbsp;为你FTP服务的IP</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">Remote file 为你要上传到FTP服务器上的文件路径及文件名</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">local file &nbsp;为本地你要上传的文件的路径。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">选择 &nbsp; put(RETR) &nbsp;为上传方式。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">填写你的FTP服务器的用户名密码。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">4.添加一个监控器：线程组---&gt;添加---&gt;监控器---&gt;Spline Visualizer</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011070116552184.jpg" alt="" style="border: 0px; width: 1013px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">一个FTP计划创建成功 :)</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">参考资料：</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><a href="http://jakarta.apache.org/jmeter/usermanual/build-ftp-test-plan.html" style="color: #1d58d1; text-decoration: none;">http://jakarta.apache.org/jmeter/usermanual/build-ftp-test-plan.html</a></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><a href="http://www.51testing.com/?uid-23852-action-viewspace-itemid-16560" style="color: #1d58d1; text-decoration: none;">http://www.51testing.com/?uid-23852-action-viewspace-itemid-16560</a></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"></p><img src ="http://www.blogjava.net/qileilove/aggbug/411422.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-24 16:55 <a href="http://www.blogjava.net/qileilove/articles/411422.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Jmeter 代理服务器录制脚本</title><link>http://www.blogjava.net/qileilove/articles/411321.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Fri, 21 Mar 2014 05:09:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/411321.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/411321.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/411321.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/411321.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/411321.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　因为Badboy只支持IE浏览器，现在又不得不到到fireFox上录制脚本才能完成，再次重温下<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">Jmeter</strong></u></a>自带的Http代理服务器，当然比起badboy，它稍稍麻烦点。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　1 &nbsp;配置很简单</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">工作</strong></u></a>台--&gt;右键添加非<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>元件--&gt;Http 代理服务器</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=44942" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/03/14982672_201403121642211LMz3.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　2 配置下接口【如果你的apache tomcat已经占用了8080接口，就不要再使用这个接口了，会报错】</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=44943" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/03/14982672_201403121642212F53q.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　3 &nbsp;设置FireFox</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px; text-align: center;"><a href="http://www.51testing.com/batch.download.php?aid=44944" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/03/14982672_201403121642213xKwR.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　4 在测试计划中添加一个Http默认请求，并设置相应的参数</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px; text-align: center;"><a href="http://www.51testing.com/batch.download.php?aid=44945" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/03/14982672_201403121642214Osfs.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　5 &nbsp;搞定，启动代理服务器</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　6 &nbsp; 打开你的FireFox ，录入测试的地址即可。</div></a></div><img src ="http://www.blogjava.net/qileilove/aggbug/411321.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-21 13:09 <a href="http://www.blogjava.net/qileilove/articles/411321.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JMeter对Oracle数据库进行压力测试</title><link>http://www.blogjava.net/qileilove/articles/411260.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Thu, 20 Mar 2014 03:35:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/411260.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/411260.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/411260.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/411260.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/411260.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><strong style="word-break: break-all; line-height: normal !important;">　步骤</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　(1) 复制<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">ORACLE</strong></u></a>的JDBC驱动JAR包文件（ojdbc14.jar）到JMeter的lib目录下。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　(2) 运行jmeter.bat</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　(3) 建立线程组：右键<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>计划-&gt;添加-&gt;Threads-&gt;线程组</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　(4) 建立JDBC Connection Configuration：右击线程组-&gt;添加-&gt;配置原件-&gt;JDBC Connection Configuration</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　(5) 在Database Connection Configuration输入Virable Name Bound to Pool的Variable Name内容</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=42951" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/10/14982672_201310291529541886Y.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　(6) 在Database Connection Configuration输入<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">数据库</strong></u></a>配置信息</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　例如：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Database URL: jdbc:oracle:thin:@192.168.1.168:1521:ptoracl</div><div style="word-break: break-all; margin: 10px 0px;">JDBC Driver class: oracle.jdbc.driver.OracleDriver</div><div style="word-break: break-all; margin: 10px 0px;">Username: lianggzone</div><div style="word-break: break-all; margin: 10px 0px;">Password:lianggzone</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">附注：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Database URL 格式：jdbc：oracle:thin:@[IP地址]:[端口号]:[实例名]</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　用户名、密码就是连接数据库的用户名和密码</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　(7) 建立JDBC Request：右击线程组-&gt;添加-&gt;Sampler-&gt;JDBC Request</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Variable Name：和上面的 JDBC Connection Configuration填写同样的内容。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">SQL</strong></u></a>&nbsp;Query：就是SQL语句。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><font color="#202859"><span style="line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/10/14982672_201310291529542Fd1w.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></span></font><br /><br /></a><div style="word-break: break-all; color: #333333; text-decoration: none; line-height: normal !important; margin: 10px 0px; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;">　(8) 添加监视器：右击线程组-&gt;添加-&gt;监视器</a></div><div style="word-break: break-all; color: #333333; text-decoration: none; line-height: normal !important; margin: 10px 0px; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;">　　<strong style="word-break: break-all; line-height: normal !important;">附注：</strong>有用的监视器</a></div><div style="word-break: break-all; color: #333333; text-decoration: none; line-height: normal !important; margin: 10px 0px; font-size: 11.818181991577148px;"><font color="#202859"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/10/14982672_201310291529543Otz2.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></font></div><div style="word-break: break-all; color: #333333; text-decoration: none; line-height: normal !important; margin: 10px 0px; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;">　　<strong style="word-break: break-all; line-height: normal !important;">补充：</strong></a></div><div style="word-break: break-all; color: #333333; text-decoration: none; line-height: normal !important; margin: 10px 0px; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;">　　（1）整体内容：</a></div><div style="word-break: break-all; color: #333333; text-decoration: none; line-height: normal !important; margin: 10px 0px; font-size: 11.818181991577148px;"><font color="#202859"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/10/14982672_201310291529544Y0Nz.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></font></div><div style="word-break: break-all; color: #333333; text-decoration: none; line-height: normal !important; margin: 10px 0px; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><font color="#202859">　　（2）其他数据库（如mysql等)的配置测试方法也与相同。</font><br /><br /></a><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank">　(8) 添加监视器：右击线程组-&gt;添加-&gt;监视器</a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank">　　<strong style="word-break: break-all; line-height: normal !important;">附注：</strong>有用的监视器</a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><font color="#202859"><span style="line-height: normal !important;"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank"><img src="http://www.51testing.com/attachments/2013/10/14982672_201310291529543Otz2.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></span></font></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank">　　<strong style="word-break: break-all; line-height: normal !important;">补充：</strong></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank">　　（1）整体内容：</a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><font color="#202859"><span style="line-height: normal !important;"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank"><img src="http://www.51testing.com/attachments/2013/10/14982672_201310291529544Y0Nz.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></span></font></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank">　　（2）其他数据库（如mysql等)的配置测试方法也与相同。</a></div><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank"></a></div><a href="http://www.51testing.com/batch.download.php?aid=42952" target="_blank"></a></div><img src ="http://www.blogjava.net/qileilove/aggbug/411260.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-20 11:35 <a href="http://www.blogjava.net/qileilove/articles/411260.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用JMeter创建数据库（Mysql）测试</title><link>http://www.blogjava.net/qileilove/articles/411163.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Tue, 18 Mar 2014 02:49:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/411163.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/411163.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/411163.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/411163.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/411163.html</trackback:ping><description><![CDATA[<p style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">我的环境：MySQL：mysql-essential-5.1.51-win32</p><p style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">　　　　　jdbc驱动：我已经上传到csdn上一个：<a href="http://download.csdn.net/source/3451945" target="_blank" style="color: #1d58d1; text-decoration: none;">http://download.csdn.net/source/3451945</a></p><p style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">　　　　　JMeter：jmeter-2.4 &nbsp;任意版本都行。</p><p style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">1.首先我们要有一个可以做测试的数据库，当然，里面要有数据，不然怎么测呢？我的上一篇文章《<span style="font-family: Arial; font-weight: bold; line-height: 25px;"><a id="ctl01_TitleUrl" href="http://www.cnblogs.com/fnng/archive/2011/07/18/2110023.html" style="color: #223355; text-decoration: none;">Eclipse连接MySQL数据库（傻瓜篇）</a></span>》，里面教你如何通过程序批量插入数据。</p><p style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">来看一下我的数据：</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011072619031421.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">我可能有点啰嗦 :） &nbsp;不管你用什么方式，你的数据库里要有点数据。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">2.</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">打开JMeter,点击测试计划，</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011072619102681.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">点击&#8220;浏览...&#8221;按钮，将你的JDBC驱动添加进来。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">3.</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">添加一个线程组，</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">右键点击&#8220;线程组&#8221;，在下面添加一个&#8220;JDBC Connection Configuration&#8221;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011072619133919.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">来配置一下JDBC Connection Configuration页面。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011072619192017.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">4.</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">右键点击&#8220;线程组&#8221;，在下面添加一个&#8220;JDBC request&#8221;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011072619280138.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">5.</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">添加断言。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">右键点击线程组----&gt;添加---&gt;断言----&gt;响应断言。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011072619343279.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">6.</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">我们来添加一些监听器来行查看</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">添加一个断言结果：</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">右键点击线程组----&gt;添加---&gt;监听器----&gt;结果断言。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">添加一个图形结果：</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">右键点击线程组----&gt;添加---&gt;监听器----&gt;图形结果。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">添加一个查看结果树：</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">右键点击线程组----&gt;添加---&gt;监听器----&gt;查看结果树。</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">下面是添加所有东东的列表：</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011072619480198.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">7.</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">在线程组页面设置用户数、启动时间、循环次数</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">点击菜单栏&#8220;运行&#8221;----&#8220;启动&#8221;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">下面是结果：</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011072619515850.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">其它的结果图片就不贴了。嘻嘻！！用图片说话，看上去简单，但比较长。。</p><img src ="http://www.blogjava.net/qileilove/aggbug/411163.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-18 10:49 <a href="http://www.blogjava.net/qileilove/articles/411163.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>测试您的 DB2 数据库: 用 JMeter 测量性能</title><link>http://www.blogjava.net/qileilove/articles/411132.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Mon, 17 Mar 2014 03:19:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/411132.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/411132.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/411132.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/411132.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/411132.html</trackback:ping><description><![CDATA[<p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;"><a name="introduction"><span style="font-size: 1.5em; font-weight: bold;">简介</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">在当今快节奏的世界中，只是完成工作是不够的。完成工作，并且要以最简便的方式完成工作，这才是关键。数据库世界也不能幸免这种对性能的渴求。客户希望能够迅速而有效地保存和提取其数据。在许多场合设置中，IBM 的 &#174; DB2&#174; Universal Database&nbsp;<span style="vertical-align: text-top; color: #666666; position: relative; top: -1px;">TM</span>&nbsp;都拥有领先的性能跟踪记录，领先于众多的数据库竞争对手。</p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">不幸的是，由于数据库或者配置中的某些设计缺陷，许多 DB2 用户可能无法获得 DB2 性能的所有益处。有许多关于 DB2 性能调整的文章和论文，DB2 中也有许多能够进行深入分析的好工具。我将在这篇文章中介绍一个工具 &#8212;&#8212; Apache 的 JMeter，这是另外一个可以添加到您的工具箱中的工具，它可以帮助您了解数据库的性能，还能帮助您进行模拟测试。</p><div style="clear: both; background-image: url(http://1.www.s81c.com/i/solid.gif); background-color: #ffffff; height: 1px; font-family: Simsun; font-size: medium; line-height: normal; background-repeat: repeat no-repeat;"></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 5px; font-size: 0.76em; clear: both; text-align: right; height: 14.545454025268555px; line-height: normal; background-color: #ffffff;"><a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#ibm-pcon" style="color: #996699; display: inline; margin: 0px; padding: 0px 0px 0px 18px; text-decoration: none; background-image: url(http://1.www.s81c.com/i/v16/icons/u_bold.gif); font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat;">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;"><a name="section1"><span style="font-size: 1.5em; font-weight: bold;">关于 Apache JMeter</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">JMeter 是 Apache Jakarta 项目麾下的一个产品。JMeter 是基于 Java&nbsp;<span style="vertical-align: text-top; color: #666666; position: relative; top: -1px;">TM</span>&nbsp;Swing 的桌面应用程序，是为进行负载测试、测量系统性能而设计的。最初，它是为测试 Web 应用程序而设计的。但是它后来进行了扩展，现在您已经可以用它来测试关系数据库了（通过 JDBC&nbsp;<span style="vertical-align: text-top; color: #666666; position: relative; top: -1px;">TM</span>）。在 JMeter 的官方站点&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html" style="color: #996699;">http://jakarta.apache.org/jmeter/</a>&nbsp;上，您可以了解关于它的更多内容。</p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">利用 JMeter，您可以确保您的数据库可以满足某些指标（例如能够处理一定数量的并发用户）。模拟测试是成功项目的关键。JMeter 可以针对 DB2 模拟出繁重的负载。这可以通过 JMeter 的多线程框架来实现。JMeter 的多线程框架允许大量线程进行并发采样。正如您将在本文后面看到的，JMeter 能为您提供图形化的反馈。</p><div style="clear: both; background-image: url(http://1.www.s81c.com/i/solid.gif); background-color: #ffffff; height: 1px; font-family: Simsun; font-size: medium; line-height: normal; background-repeat: repeat no-repeat;"></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 5px; font-size: 0.76em; clear: both; text-align: right; height: 14.545454025268555px; line-height: normal; background-color: #ffffff;"><a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#ibm-pcon" style="color: #996699; display: inline; margin: 0px; padding: 0px 0px 0px 18px; text-decoration: none; background-image: url(http://1.www.s81c.com/i/v16/icons/u_bold.gif); font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat;">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;"><a name="section2"><span style="font-size: 1.5em; font-weight: bold;">获得 JMeter 并设置您的测试环境</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">您可以从&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html" style="color: #996699;">http://jakarta.apache.org/builds/jakarta-jmeter/release/</a>&nbsp;下载 JMeter 的最新发行版。在我撰写这篇文章时，最新的 JMeter 版本是 1.8。JMeter 要求在 Sun 的 JDK1.4（或者更高）环境中工作。IBM JDK（指当前版本）似乎与 JMeter 不兼容。JMeter 已经在各种 UNIX&#174; 变体 (包括 Solaris 和 Linux) 和 Windows&#174;（98&#174;、NT&#174; 和 2000&#174;）上通过了测试。</p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">为了方便我们对 DB2 进行的 JDBC 测试，需要把 DB2 的 JDBC 驱动程序复制到&nbsp;<code style="font-size: small !important;">&lt;jmeter 安装目录&gt;\jakarta-jmeter\lib</code>&nbsp;目录下。对于 DB2 8.1 ，在默认安装情况下，DB2 驱动程序的位置是&nbsp;<code style="font-size: small !important;">c:\program files\ibm\sqllib\java\db2java.zip</code>。奇怪的是，如果 DB2 的 JDBC 驱动程序以 zip 文件命名，JMeter 将找不到 DB2 的 JDBC 驱动程序。要解决这个问题，您必须将文件名更改为&nbsp;<code style="font-size: small !important;">.JAR</code>&nbsp;文件。您可以把 lib 目录中的文件改名为&nbsp;<code style="font-size: small !important;">db2java.jar</code>。另一方面，如果想测试 DB2 8.1 Java Common Client (JCC) 驱动程序，只需将&nbsp;<code style="font-size: small !important;">db2jcc.jar</code>文件复制到 JMeter 的 lib 目录下即可（不用更改名称）。</p><div style="clear: both; background-image: url(http://1.www.s81c.com/i/solid.gif); background-color: #ffffff; height: 1px; font-family: Simsun; font-size: medium; line-height: normal; background-repeat: repeat no-repeat;"></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 5px; font-size: 0.76em; clear: both; text-align: right; height: 14.545454025268555px; line-height: normal; background-color: #ffffff;"><a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#ibm-pcon" style="color: #996699; display: inline; margin: 0px; padding: 0px 0px 0px 18px; text-decoration: none; background-image: url(http://1.www.s81c.com/i/v16/icons/u_bold.gif); font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat;">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;"><a name="section3"><span style="font-size: 1.5em; font-weight: bold;">在沙箱中放沙子</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">在我们开始使用 JMeter 之前，我们需要建立一个有一些测试数据的数据库。</p><ol style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-right: 5px; padding-bottom: 5px; font-size: 0.76em; font-family: Simsun; line-height: normal; background-color: #ffffff;"><li style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 3px;">在 DB2 的命令行处理器中输入以下内容：<table width="100%" cellpadding="0" cellspacing="0" border="0" style="font-size: 0.8em;"><tbody><tr><td style="border-style: solid; border-color: #cccccc; padding: 2px 2px 5px; background-color: #f7f7f7 !important;"><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, Liberation, fixed, monospace; font-size: 11px; overflow: auto;">  create db loaddb  </pre></td></tr></tbody></table><br /></li><li style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 3px;">连接&nbsp;<code style="font-size: small !important;">loaddb</code>&nbsp;数据库，如下所示：<table width="100%" cellpadding="0" cellspacing="0" border="0" style="font-size: 0.8em;"><tbody><tr><td style="border-style: solid; border-color: #cccccc; padding: 2px 2px 5px; background-color: #f7f7f7 !important;"><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, Liberation, fixed, monospace; font-size: 11px; overflow: auto;">  connect to loaddb user db2admin using db2admin</pre></td></tr></tbody></table><br /></li><li style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 3px;">建立一个表，保存我们的测试数据：<table width="100%" cellpadding="0" cellspacing="0" border="0" style="font-size: 0.8em;"><tbody><tr><td style="border-style: solid; border-color: #cccccc; padding: 2px 2px 5px; background-color: #f7f7f7 !important;"><pre style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, Liberation, fixed, monospace; font-size: 11px; overflow: auto;">  create table loadtable (col1 varchar(25) not null,  col2 varchar(25) not null,  col3 varchar(25) not null)  </pre></td></tr></tbody></table><br /></li><li style="font-family: arial, nsimsun, sans-serif; margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 3px;">用大量记录填充表，这样我们才能用 JMeter 来测试查询性能。我用了一个小小的 JDBC 程序来完成这项工作，在&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#清单1" style="color: #996699;">清单 1&nbsp;</a>中可以看到它，该程序将在可装入表中插入 30,000 条记录。然后编译并执行这段代码，用测试数据填充可装入表。</li></ol><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;"><a name="清单1"></a>清单 1. 将记录插入数据库&nbsp;<br /></p><table width="100%" cellpadding="0" cellspacing="0" border="0" style="font-size: 0.8em; color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td style="font-family: arial, nsimsun, sans-serif; border-style: solid; border-color: #cccccc; padding: 2px 2px 5px; background-color: #f7f7f7 !important;"><pre style="width: 694px; margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, Liberation, fixed, monospace; font-size: 11px; overflow: auto;">  package com.ibm.jmetertest;  import java.sql.*;    public class JMeterPopulator  {    public static void main(String[] args)    {      try      {        Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");  	String dbName = "loaddb";  	String url = "jdbc:db2:" + dbName;  	String userName = "db2admin";  	String password = "db2admin";  	Connection con            = DriverManager.getConnection(url,userName, password);  	int numOfTestRecords = 30000;  	PreparedStatement statement            = con.prepareStatement("INSERT INTO LOADTABLE VALUES(?,?,?)");  	for (int i =0; i&lt;numOfTestRecords; i++)  	{  	  statement.setString(1,"Col1Test-" + i);  	  statement.setString(2,"Col2Test-" + i);  	  statement.setString(3,"Col3Test-" + i);  	  statement.executeUpdate();  	  System.out.println(i);  	}      }      catch(Exception e)      {         System.out.println("An error has occurred: " + e.toString());         e.printStackTrace();      }    }  }    </pre></td></tr></tbody></table><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">现在我们有了相当数量的记录，让我们用 JMeter 来测试一下查询性能。</p><div style="clear: both; background-image: url(http://1.www.s81c.com/i/solid.gif); background-color: #ffffff; height: 1px; font-family: Simsun; font-size: medium; line-height: normal; background-repeat: repeat no-repeat;"></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 5px; font-size: 0.76em; clear: both; text-align: right; height: 14.545454025268555px; line-height: normal; background-color: #ffffff;"><a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#ibm-pcon" style="color: #996699; display: inline; margin: 0px; padding: 0px 0px 0px 18px; text-decoration: none; background-image: url(http://1.www.s81c.com/i/v16/icons/u_bold.gif); font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat;">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;"><a name="section4"><span style="font-size: 1.5em; font-weight: bold;">进入 JMeter</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">要启动 JMeter，需要运行&nbsp;<code style="font-size: small !important;">&lt;jmeter 安装目录 &gt;\jakarta-jmeter\bin</code>&nbsp;目录下的&nbsp;<code style="font-size: small !important;">jmeter.bat</code>&nbsp;文件。</p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">当启动 JMeter 时，您会看到一个主屏幕，屏幕左边有一个面板，其中还没有定义测试计划（参见&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig1" style="color: #996699;">图 1</a>）。在 JMeter 中，一个测试计划是由一个或多个线程组构成的。线程代表模拟用户，&nbsp;<em>线程组（thread group）</em>是一组模拟用户。</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig1" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 1. JMeter 的主屏幕&nbsp;</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="JMeter 的主屏幕" height="447" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/startup.gif" width="580" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">让我们从建立线程组开始。方法是右击&nbsp;<strong>TestPlan</strong>&nbsp;节点，选择&nbsp;<strong>Add =&gt; Thread Group</strong>。参见&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig2" style="color: #996699;">图 2</a>。</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig2" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 2. 添加线程组&nbsp;</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="增加线程组" height="238" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/addthreadgroup.gif" width="340" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">在下一个屏幕中（参见&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig3" style="color: #996699;">图 3</a>），您可以定义测试中所要包含的线程或模拟用户的数量。&nbsp;<em>等候周期（Ramp-Up Period）</em>指定了 JMeter 在向数据库暴露模拟用户之前应当等待的时间。例如，如果我们有 30 个模拟用户，等候周期为15秒，那么我们就会每秒向数据库暴露 2 个用户(30 个用户/15 秒)。如果将等候周期设置为 0，JMeter 会自动一次启动所有模拟用户。循环计数（Loop Count）指定了 JMeter 要重复测试的次数。在这个屏幕中，还可以修改我们的线程组名称。接下来按&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig3" style="color: #996699;">图 3</a>&nbsp;所示输入设置，这将为我们提供 30 个同时启动的用户。该测试将运行 100 次。</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig3" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 3. 线程组的设置&nbsp;</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="线程组的设置" height="247" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/threadgroupdefined.gif" width="395" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><div style="clear: both; background-image: url(http://1.www.s81c.com/i/solid.gif); background-color: #ffffff; height: 1px; font-family: Simsun; font-size: medium; line-height: normal; background-repeat: repeat no-repeat;"></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 5px; font-size: 0.76em; clear: both; text-align: right; height: 14.545454025268555px; line-height: normal; background-color: #ffffff;"><a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#ibm-pcon" style="color: #996699; display: inline; margin: 0px; padding: 0px 0px 0px 18px; text-decoration: none; background-image: url(http://1.www.s81c.com/i/v16/icons/u_bold.gif); font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat;">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;"><a name="section5"><span style="font-size: 1.5em; font-weight: bold;">与数据库对话</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">现在，我们将指定如何与 DB2 UDB 通信。我们要以 JDBC 请求的形式与 DB2 UDB 进行通信。右击刚才建立的线程组（&nbsp;<strong>DB2 Test</strong>），选择&nbsp;<strong>Add =&gt; Sampler =&gt; JDBC Request</strong>。</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig4" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 4. 设置 JDBC 连接&nbsp;</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="设置 JDBC 连接" height="312" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/jdbcrequest.gif" width="498" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">然后，您将看到一个屏幕，我们可以在其中设置一些只与 DB2 有关的信息，这样才能与我们的 DB2 数据库进行对话。这些信息包括：JDBC URL、JDBC 驱动程序，以及我们的用户名和口令。在这个屏幕上， 我们还可以指定有关连接池的信息，以及想要应用到数据库上的 SQL 查询。</p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">接下来，我们使用&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig5" style="color: #996699;">图 5</a>&nbsp;所示的值进行测试。对于那些不太熟悉连接池的读者来说，连接池就是一组数据库连接的维护，以便应用程序重复使用。数据库连接池在 Web 环境中很常见，因为 Web 用户连接、断开连接非常频繁。在数据库世界中，获得数据库连接是一项昂贵的操作。我们必须建立连接、维持连接，然后在操作完成的时候断开连接。利用 JMeter，我们可以分析连接池的优势。</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig5" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 5. 指定数据库的连接信息</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="指定数据库的连接信息" height="437" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/jdbcrequestdetails.gif" width="457" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><div style="clear: both; background-image: url(http://1.www.s81c.com/i/solid.gif); background-color: #ffffff; height: 1px; font-family: Simsun; font-size: medium; line-height: normal; background-repeat: repeat no-repeat;"></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 5px; font-size: 0.76em; clear: both; text-align: right; height: 14.545454025268555px; line-height: normal; background-color: #ffffff;"><a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#ibm-pcon" style="color: #996699; display: inline; margin: 0px; padding: 0px 0px 0px 18px; text-decoration: none; background-image: url(http://1.www.s81c.com/i/v16/icons/u_bold.gif); font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat;">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;"><a name="section6"><span style="font-size: 1.5em; font-weight: bold;">用监听器监听结果</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">这时，我们真正定义了一个 JMeter 测试，它将测试我们的 DB2 数据库。此时我们面临的问题是没有办法看到测试结果。为了解决这个问题，请右击&nbsp;<strong>JDBC Request</strong>，然后选择&nbsp;<strong>Add =&gt; Listener =&gt; Graph Results</strong>&nbsp;，如下图所示：</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig6" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 6. 指定图形化结果&nbsp;</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="指定图形化结果" height="251" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/graphresults.gif" width="580" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><div style="clear: both; background-image: url(http://1.www.s81c.com/i/solid.gif); background-color: #ffffff; height: 1px; font-family: Simsun; font-size: medium; line-height: normal; background-repeat: repeat no-repeat;"></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 5px; font-size: 0.76em; clear: both; text-align: right; height: 14.545454025268555px; line-height: normal; background-color: #ffffff;"><a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#ibm-pcon" style="color: #996699; display: inline; margin: 0px; padding: 0px 0px 0px 18px; text-decoration: none; background-image: url(http://1.www.s81c.com/i/v16/icons/u_bold.gif); font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat;">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;"><a name="section7"><span style="font-size: 1.5em; font-weight: bold;">把您的脚放在 JMeter 的踏板上</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">现在是启动 JMeter 测试的时候了。从主菜单中选择&nbsp;<strong>Run</strong>&nbsp;，然后选择&nbsp;<strong>Start</strong>，如&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig7" style="color: #996699;">图 7</a>&nbsp;所示。</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig7" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 7. 启动测试&nbsp;</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="启动测试" height="195" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/start.gif" width="283" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">请注意在屏幕右上角闪亮的屏幕区域。这个区域表明测试正在运行。在这个时候，您应当看到，图形被有关信息填充，信息的内容是执行指定查询所需要的时间（平均时间）（参见&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig8" style="color: #996699;">图 8</a>）。</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig8" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 8. 进行测试时以图形方式显示结果&nbsp;</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="进行测试时以图形方式显示结果" height="564" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/samplegraph.gif" width="580" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">您可能会考虑采用更多并发用户（线程组中的线程），来查看增加用户负载对于执行相同查询的平均时间的影响。您可能要给查询所涉及的字段添加索引，然后实际查看索引为具体数据库环境带来的好处。</p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">JMeter 允许您通过使用&nbsp;<strong>File =&gt; Save Test Plan</strong>&nbsp;保存测试计划，从而指定保存 JMeter 测试计划的位置。</p><div style="clear: both; background-image: url(http://1.www.s81c.com/i/solid.gif); background-color: #ffffff; height: 1px; font-family: Simsun; font-size: medium; line-height: normal; background-repeat: repeat no-repeat;"></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 5px; font-size: 0.76em; clear: both; text-align: right; height: 14.545454025268555px; line-height: normal; background-color: #ffffff;"><a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#ibm-pcon" style="color: #996699; display: inline; margin: 0px; padding: 0px 0px 0px 18px; text-decoration: none; background-image: url(http://1.www.s81c.com/i/v16/icons/u_bold.gif); font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat;">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;"><a name="section8"><span style="font-size: 1.5em; font-weight: bold;">JMeter 真的在工作吗？</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">不幸的是，JMeter 的错误报告功能不那么强大。实际上，在我使用这个工具的时候，我以为错误报告功能起作用，而实际上它没有。因此，您应当考虑使用&nbsp;<em>断言（assertions）</em>特性。断言允许 JMeter 用户审核数据库服务器的响应，并&#8220;断言&#8221;响应中确实存在某项数据。</p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">在我们进行断言之前，需要知道我们想从查询中得到什么结果。我们可以在命令行处理器中运行查询，得到我们想要的结果，如&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig9" style="color: #996699;">图 9</a>&nbsp;所示。</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig9" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 9. 示例查询&nbsp;</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="示例查询" height="260" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/selectquery.gif" width="547" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">要添加断言，需要右击&nbsp;<strong>JDBC Request</strong>，然后选择&nbsp;<strong>Add =&gt; Assertions =&gt; Response Assertion</strong>，如&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig10" style="color: #996699;">图 10</a>&nbsp;所示。</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig10" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 10. 添加断言&nbsp;</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="添加断言" height="244" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/responseassert.gif" width="580" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">您可以在该屏幕中添加文本断言。单击&nbsp;<strong>Add</strong>&nbsp;，然后在&nbsp;<strong>Patterns to Test</strong>&nbsp;字段中添加文本&nbsp;<code style="font-size: small !important;">Col1Test-20015</code>&nbsp;，因为我们知道在返回结果中应当包含该文本（参见&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig11" style="color: #996699;">图 11</a>）。</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig11" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 11. 将文本添加到测试中&nbsp;</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="将文本添加到测试中" height="276" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/responseassertiondetails.gif" width="462" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">现在，我们要添加一个监听器，以监听响应断言。右击&nbsp;<strong>JDBC Request</strong>，然后选择&nbsp;<strong>Add =&gt; Listener =&gt; Assertion Results</strong>，如<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig12" style="color: #996699;">图 12</a>&nbsp;所示。</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig12" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 12. 添加断言监听器</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="添加断言监听器" height="236" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/addassertlistener.gif" width="580" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">这样您就可以看到断言结果屏幕（&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig13" style="color: #996699;">图 13</a>），您甚至可以在该屏幕中指定一个数据文件，把断言数据写入数据文件。</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig13" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 13. 断言结果屏幕&nbsp;</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="断言结果屏幕" height="270" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/assertresultsscreen.gif" width="580" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">现在，当您运行测试对象的时候，您应该看到用否定或肯定断言填充的断言结果屏幕，是肯定还是否定则取决于是否满足断言中的条件。</p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;"><a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig14" style="color: #996699;">图 14</a>&nbsp;显示的是成功的断言</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig14" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 14. 断言测试为肯定时的结果&nbsp;</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="断言测试为肯定时的结果" height="278" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/assertionsuccess.gif" width="550" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">如果修改断言，查找&nbsp;<code style="font-size: small !important;">Col1Test-40000</code>&nbsp;（我们知道数据库数据中没有这个文本），那么我们将得到类似&nbsp;<a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#fig15" style="color: #996699;">图 15</a>&nbsp;所示的屏幕。</p><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a name="fig15" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;"><strong style="font-size: 0.76em; padding: 0.3em 5px 0.7em; font-family: arial, sans-serif;">图 15. 断言测试结果为否定时的结果&nbsp;</strong></a><br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><img alt="断言测试结果为否定时的结果" height="253" src="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/images/assertfailed.gif" width="507" style="border: 0px; padding: 0.3em 5px 0.7em; font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" />&nbsp;<br style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><div style="clear: both; background-image: url(http://1.www.s81c.com/i/solid.gif); background-color: #ffffff; height: 1px; font-family: Simsun; font-size: medium; line-height: normal; background-repeat: repeat no-repeat;"></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 5px; font-size: 0.76em; clear: both; text-align: right; height: 14.545454025268555px; line-height: normal; background-color: #ffffff;"><a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0303bhogal/0303bhogal.html#ibm-pcon" style="color: #996699; display: inline; margin: 0px; padding: 0px 0px 0px 18px; text-decoration: none; background-image: url(http://1.www.s81c.com/i/v16/icons/u_bold.gif); font-weight: bold; background-position: 0px -1px; background-repeat: no-repeat no-repeat;">回页首</a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;"><a name="N102A8"><span style="font-size: 1.5em; font-weight: bold;">结束语</span></a></p><p style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 0.3em 5px 0.7em; font-size: 0.76em; line-height: normal; background-color: #ffffff;">可以利用 JMeter 在系统、服务器和网络上模拟繁重的负载。本文中，我们用 JMeter 分析了 DB2 数据库的查询性能。我们只触及到 JMeter 功能中很表面的部分。可以用 JMeter 来建立相当复杂却很有意义的测试计划。JMeter 会以图形和活动曲线的形式，快速提供关于系统性能的可视反馈。您可以用 JMeter 提供的数据来确保能够在调整您的企业运作的情况下获得最佳性能。</p><div style="clear: both; background-image: url(http://1.www.s81c.com/i/solid.gif); background-color: #ffffff; height: 1px; font-family: Simsun; font-size: medium; line-height: normal; background-repeat: repeat no-repeat;"></div><p ibm-back-to-top"="" style="font-family: arial, nsimsun, sans-serif; margin: 0px; padding: 5px; font-size: 0.76em; clear: both; text-align: right; height: 14.545454025268555px; line-height: normal; background-color: #ffffff;"><br /></p><img src ="http://www.blogjava.net/qileilove/aggbug/411132.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-17 11:19 <a href="http://www.blogjava.net/qileilove/articles/411132.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JMeter基础之—录制脚本</title><link>http://www.blogjava.net/qileilove/articles/411023.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Fri, 14 Mar 2014 03:15:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/411023.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/411023.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/411023.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/411023.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/411023.html</trackback:ping><description><![CDATA[<div id="cnblogs_post_body" style="margin-bottom: 20px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><p style="margin-top: 6pt; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">Jmeter&nbsp;<span style="font-family: 宋体;">是一个非常流行的性能测试工具，虽然与</span>LoadRunner<span style="font-family: 宋体;">相比有很多不足，比如：它结果分析能力没有</span>LoadRunner<span style="font-family: 宋体;">详细；很它的优点也有很多：</span></p><p style="margin: 6pt 0cm 0.0001pt 18pt; font-size: 13px; line-height: 19.5px; text-indent: -18pt;"><span style="font-family: Wingdings;">&nbsp; l<span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span style="font-family: 宋体;">开源，他是一款开源的免费软件，使用它你不需要支付任何费用，</span></p><p style="margin: 6pt 0cm 0.0001pt 18pt; font-size: 13px; line-height: 19.5px; text-indent: -18pt;"><span style="font-family: Wingdings;">&nbsp;&nbsp;l<span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span style="font-family: 宋体;">小巧，相比</span>LR<span style="font-family: 宋体;">的庞大（最新</span>LR11<span style="font-family: 宋体;">将近</span>4GB<span style="font-family: 宋体;">），它非常小巧，不需要安装，但需要</span>JDK<span style="font-family: 宋体;">环境，因为它是使用</span>java<span style="font-family: 宋体;">开发的工具。</span></p><p style="margin: 6pt 0cm 0.0001pt 18pt; font-size: 13px; line-height: 19.5px; text-indent: -18pt;"><span style="font-family: Wingdings;"><span style="font-family: Verdana;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>l<span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span style="font-family: 宋体;">功能强大，</span>jmeter<span style="font-family: 宋体;">设计之初只是一个简单的</span>web<span style="font-family: 宋体;">性能测试工具，但经过不段的更新扩展，现在可以完成数据库、</span>FTP<span style="font-family: 宋体;">、</span>LDAP<span style="font-family: 宋体;">、</span>WebService<span style="font-family: 宋体;">等方面的测试。因为它的开源性，当然你也可以根据自己的需求扩展它的功能。</span></p><p style="margin-top: 6pt; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;"><span style="font-family: 宋体;">我觉得它更像一个瑞士军刀，小巧，且功能齐全。初次认识</span>Jmeter<span style="font-family: 宋体;">的时候，我觉得它不好，是因为相比</span>LR<span style="font-family: 宋体;">来说，它没有脚本录制功能，也许不是没有，只是我不知道，因为文档上介绍的是这样，我要做一个</span>web<span style="font-family: 宋体;">性能测试的话，就手动的一个个添加循环控制器、</span>http<span style="font-family: 宋体;">信息管理头、</span>http<span style="font-family: 宋体;">请求等等各种元件。如果测试的脚本较多时，这无疑是个体力活。</span></p><p style="margin-top: 6pt; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Badboy<span style="font-family: 宋体;">是一款不错</span>web<span style="font-family: 宋体;">自动化测试工具，利用它来录制脚本，并且录制的脚本可以直接保存为</span>JMeter<span style="font-family: 宋体;">文件来使用。我无疑给我们带来了很大我方便。</span></p><p style="margin-top: 6pt; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">----------------------<span style="font-family: 宋体;">我的环境</span>------------</p><p style="margin-top: 6pt; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">Badboy&nbsp;&nbsp;version 2.1.1</p><p style="margin-top: 6pt; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">Apache&nbsp;&nbsp;JMeter-2.3.4 (<span style="font-family: 宋体;">需要</span>JDK<span style="font-family: 宋体;">环境来运行</span>)</p><p style="margin-top: 6pt; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">--------------------------------------------</p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;"><strong><span style="font-family: 宋体;">第一种方法：通过</span>bodboy<span style="font-family: 宋体;">来录制脚本。</span></strong></p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">1.<span style="font-family: 宋体;">打开人</span>badboy<span style="font-family: 宋体;">工具，点击工栏目上的红色圆形按钮，在地址栏目中输入被测试项目的地址。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011082012224922.jpg" alt="" width="707" height="412" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;"><span style="font-family: 宋体;">录制完成后，点击工具栏旁边黑色按钮，结束录制。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;"><span style="font-family: 宋体;">选择&#8220;文件&#8221;</span>--<span style="font-family: Wingdings;">&#224;</span>Export to Jmeter&#8230;</p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011082012232191.jpg" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">2.<span style="font-family: 宋体;">打开</span>Jmeter<span style="font-family: 宋体;">工具，选择&#8220;文件&#8221;</span>--<span style="font-family: Wingdings;">&gt;</span><span style="font-family: 宋体;">&#8220;打开&#8221;选择刚才保存的文件(.jmx类型)，将文件导入进来了。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011082012234447.jpg" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;"><strong><span style="font-family: 宋体;">第二种方法，通过</span>JMeter<span style="font-family: 宋体;">自身设置来录制脚本。</span></strong></p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;"><span style="font-family: 宋体;">这种方法是我才发现的（鄙视一下自己的无知，嘻嘻</span>~<span style="font-family: 宋体;">！），觉得方法比较简单。</span>&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; margin-left: 18pt; font-size: 13px; line-height: 19.5px; text-indent: -18pt;">1.<span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 宋体;">打开</span>JMeter<span style="font-family: 宋体;">工具</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;"><span style="font-family: 宋体;">创建一个线程组（右键点击&#8220;测试计划&#8221;---&gt;&#8220;添加&#8221;----&gt;&#8220;线程组&#8221;）</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;"><span style="font-family: 宋体;">创建一个http代理服务器（右键点击&#8220;工作台&#8221;</span><span style="font-family: 宋体;">---&gt;&#8220;添加&#8221;</span><span style="font-family: 宋体;">---&gt;&#8220;非测试元件&#8221;</span><span style="font-family: 宋体;">---&gt;&#8220;http代理服务器&#8221;</span><span style="font-family: 宋体;">）</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">完整的设置参照下图：</p><p style="margin-top: 10px; margin-bottom: 10px;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011082012304830.jpg" alt="" width="817" height="478" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px;">2. &nbsp;下面来设置一下IE浏览器</p><p style="margin-top: 10px; margin-bottom: 10px;">IE<span style="font-family: 宋体;">---&gt;&#8220;internet属性&#8221;</span><span style="font-family: 宋体;">---&gt;&#8220;连接&#8221;</span><span style="font-family: 宋体;">---&gt;&#8220;局域网设置&#8221;</span></p><p style="margin-top: 10px; margin-bottom: 10px;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011082012351321.jpg" alt="" width="415" height="412" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px;">设置为本机IP就可以了，注意端口号要与Jmeter上的端口号一致。默认都是8080端口。</p><p style="margin-top: 10px; margin-bottom: 10px;">3. &nbsp; 现在点击jmeter上的&#8220;启动&#8221;按钮，打开浏览器输入需要录制web项目地址，jmeter会自动记录你IE所访问的页面。</p><p style="margin-top: 10px; margin-bottom: 10px;"><img src="http://pic002.cnblogs.com/images/2011/311516/2011082012432788.jpg" alt="" width="554" height="392" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">PS:第二种方法是我刚才知道的一种，关于这两种方法哪个更好，现在还不知道，但第二方法有通过IE浏览器辅助的，我想可能只要IE能打开的，它都能记录，但它录制的脚本看上去比较乱（感觉上）</p><p style="margin-top: 10px; margin-bottom: 10px; font-size: 13px; line-height: 19.5px;">还就是http代理服务器的设置，（比如：分组：每一个组放入一个新的服务器---只有这一个选项才能正常录制），有时间再仔细比较一下两种方法的不同之处。</p></div><div id="MySignature" style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"></div><div style="clear: both; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"></div><div id="blog_post_info_block" style="margin-top: 20px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><div id="blog_post_info"><div id="BlogPostCategory" style="margin-bottom: 10px;">分类:&nbsp;<a href="http://www.cnblogs.com/fnng/category/345478.html" style="color: #1d58d1; text-decoration: none;">jmeter</a></div></div></div><img src ="http://www.blogjava.net/qileilove/aggbug/411023.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-14 11:15 <a href="http://www.blogjava.net/qileilove/articles/411023.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JMeter基础之一 一个简单的性能测试</title><link>http://www.blogjava.net/qileilove/articles/410975.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Thu, 13 Mar 2014 05:04:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410975.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410975.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410975.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410975.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410975.html</trackback:ping><description><![CDATA[<p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">上一节中，我们了解了jmeter的一此主要元件，那么这些元件如何使用到性能测试中呢。这一节创建一个简单的测试计划来使用这些元件。该计划对应的测试需求。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">1）测试目标网站是fnng.cnblogs.com&nbsp;&nbsp;和&nbsp;tt-topia.rhcloud.com</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">2）测试目的是该网站在负载达到20&nbsp;QPS&nbsp;时的响应时间。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>QPS&nbsp;解释</strong></span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　QPS :&nbsp;Query&nbsp;Per&nbsp;Second&nbsp;每秒查询率。是一台查询服务器每秒能够处理的查询次数。在因特网上，作为域名系统服务器的机器的性能经常用每秒查询率来衡量。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　为了达成预期的测目的，需要需要在jmeter中建立一个测试计划。因为本次测试仅要求完成对fnng.cnblogs.com&nbsp;&nbsp;和&nbsp;tt-topia.rhcloud.com&nbsp;两个博客首页请求，因此只需要使用HTTP&nbsp;Request&nbsp;Sampler&nbsp;即可。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>建立测试计划</strong></span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">&nbsp;　　启动jmeter后，jmeter会自动生成一个空的测试计划，用户可以基于该测试计划建立自己的测试计划。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 18pt;"><strong>添加线程组</strong></span></p><hr style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;" /><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;&nbsp;　　<span style="font-size: 15px;">一个性能测试请求负载是基于一个线程组完成的。一个测试计划必须有一个线程组。测试计划添加线程组非常简单。在测试计划右键弹出下拉菜单（添加--&gt;Threads(Users)---&gt;线程组）中选择线程组即可。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">&nbsp;　　jmeter中&nbsp;每个测试计划至少需要包含一个线程组，当然也可以在一个计划中创建多个线程组，那么多个线程组之间又会怎样的顺序执行（串行还是并行）？在测试计划下面多个线程是并行执行的，也就是说这些线程组是同时被初始化并同时执行线程组下的Sampler的。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;<img src="http://images.cnitblog.com/blog/311516/201212/22204824-2c8a746fc12d4aeb9ba49613e8875aa6.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;<img src="http://images.cnitblog.com/blog/311516/201212/22204908-d7cbc28470fd4317b70e0f1c540265b4.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;　　<span style="font-size: 15px;">线程组主要包含三个参数：线程数、准备时长（Ramp-Up&nbsp;Period(in&nbsp;seconds)）、循环次数。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>线程数</strong>：虚拟用户数。一个虚拟用户占用一个进程或线程。设置多少虚拟用户数在这里也就是设置多少个线程数。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>准备时长</strong>：&nbsp;设置的虚拟用户数需要多长时间全部启动。如果线程数为20&nbsp;，准备时长为10&nbsp;，那么需要10秒钟启动20个线程。也就是每秒钟启动2个线程。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>循环次数</strong>：每个线程发送请求的次数。如果线程数为20&nbsp;，循环次数为100&nbsp;，那么每个线程发送100次请求。总请求数为20*100=2000&nbsp;。如果勾选了&#8220;永远&#8221;，那么所有线程会一直发送请求，一到选择停止运行脚本。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　设置合理的线程数对于能否达到测试目标有决定性的影响。在本例中，要求得到网站首页在20&nbsp;QPS&nbsp;负载情况下的响应时间，如果如果线程数量设置的过小，则很可能无法达到设定的QPS要求。另外，设置合理的循环次数也很重要，除了上面介绍的固定循环次数与永远外；也可以灵活的选择设定测试运行时间。勾选&#8220;调度器&#8221;，进行调度器配置。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 18pt;"><strong>添加HTTP请求</strong></span></p><hr style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;" /><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　添加完成线程组后，在线程组上右键菜单（添加---&gt;Sampler---&gt;HTTP请求）选择HTTP请求。对于jmeter来说，取样器（Sampler）是与服务器进行交互的单元。一个取样器通常进行三部分的工作：</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">向服务器发送请求</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">记录服务器的响应数据</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">记录相应时间信息</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://images.cnitblog.com/blog/311516/201212/22205103-1be5c567250c4163a0e51b5340ff586d.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://images.cnitblog.com/blog/311516/201212/22205148-4c9bf545a42f4a3fad8bf6409c567c74.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;　　<span style="font-size: 15px;">一个HTTP请求有着许多的配置参数，下面将详细介绍：</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>名称</strong>：本属性用于标识一个取样器，建议使用一个有意义的名称。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>注释</strong>：对于测试没有任何作用，仅用户记录用户可读的注释信息。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>服务器名称或IP</strong>&nbsp;：HTTP请求发送的目标服务器名称或IP地址。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>端口号</strong>：目标服务器的端口号，默认值为80&nbsp;。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>协议</strong>：向目标服务器发送HTTP请求时的协议，可以是http或者是https&nbsp;，默认值为http&nbsp;。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>方法</strong>：发送HTTP请求的方法，可用方法包括GET、POST、HEAD、PUT、OPTIONS、TRACE、DELETE等。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>Content&nbsp;encoding</strong>&nbsp;：内容的编码方式，默认值为iso8859</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>路径</strong>：目标URL路径（不包括服务器地址和端口）</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>自动重定向</strong>：如果选中该选项，当发送HTTP请求后得到的响应是302/301时，JMeter&nbsp;自动重定向到新的页面。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>Use&nbsp;keep&nbsp;Alive</strong>&nbsp;：&nbsp;当该选项被选中时，jmeter&nbsp;和目标服务器之间使用&nbsp;Keep-Alive方式进行HTTP通信，默认选中。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>Use&nbsp;multipart/from-data&nbsp;for&nbsp;HTTP&nbsp;POST</strong>&nbsp;：当发送HTTP&nbsp;POST&nbsp;请求时，使用Use&nbsp;multipart/from-data方法发送，默认不选中。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>同请求一起发送参数</strong>&nbsp;：&nbsp;在请求中发送URL参数，对于带参数的URL&nbsp;，jmeter提供了一个简单的对参数化的方法。用户可以将URL中所有参数设置在本表中，表中的每一行是一个参数值对（对应RUL中的&nbsp;名称1=值1）。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>同请求一起发送文件</strong>：在请求中发送文件，通常，HTTP文件上传行为可以通过这种方式模拟。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>从HTML文件获取所有有内含的资源</strong>：当该选项被选中时，jmeter在发出HTTP请求并获得响应的HTML文件内容后，还对该HTML进行Parse&nbsp;并获取HTML中包含的所有资源（图片、flash等），默认不选中，如果用户只希望获取页面中的特定资源，可以在下方的Embedded&nbsp;URLs&nbsp;must&nbsp;match&nbsp;文本框中填入需要下载的特定资源表达式，这样，只有能匹配指定正则表达式的URL指向资源会被下载。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>用作监视器</strong>：此取样器被当成监视器，在Monitor&nbsp;Results&nbsp;Listener&nbsp;中可以直接看到基于该取样器的图形化统计信息。默认为不选中。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>Save&nbsp;response&nbsp;as&nbsp;MD5&nbsp;hash?</strong>&nbsp;：选中该项，在执行时仅记录服务端响应数据的MD5值，而不记录完整的响应数据。在需要进行数据量非常大的测试时，建议选中该项以减少取样器记录响应数据的开销。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　在这里我们添加两个HTTP请求，分别用于对fnng.cnblogs.com&nbsp;&nbsp;和&nbsp;tt-topia.rhcloud.com发送请求。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 18pt;"><strong>设置QPS限制</strong></span></p><hr style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;" /><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">　　<span style="font-size: 15px;">本次性能测试的需求中提到测试的目的是&#8220;了解博客的首页在负载达到20&nbsp;QPS时的响应时间&#8221;，因此需要控制向博客首页发送请求的负载为20QPS。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　一种可行的方法是逐步调整测试计划中的线程计算的数量以及为取样器（Sampler）添加定时器（Timer），以使HTTP取样器发出的请求的QPS保持在20个左右。但这种方法耗时耗力，需要经过多次尝试才能达到；另一方法，完全通过设置定时器来控制QPS，一旦取样器的响应时间发生改变（网络环境发生改变），就需要重新调整定时器的等待时间。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　Jmeter提供了一个非常有用的定时器，称为Constant&nbsp;Throughput&nbsp;Timer&nbsp;（常数吞吐量定时器），该定时器可以方便地控制给定的取样器发送请求的吞吐量。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　右键点击fnng.cnblogs.com&nbsp;，弹出菜单（添加---&gt;定时器---&gt;Constant&nbsp;Throughput&nbsp;Timer）选择Constant&nbsp;Throughput&nbsp;Timer</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://images.cnitblog.com/blog/311516/201212/22205404-d54593634ff84bb58da5add5dfbaedd9.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://images.cnitblog.com/blog/311516/201212/22205424-d71bcc60d1194d3bb798f17c75b3cd7a.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">Constant&nbsp;Throughput&nbsp;Timer&nbsp;的主要属性介绍：</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>名称</strong>&nbsp;：定时器的名称</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>Target&nbsp;throughput（in&nbsp;samples&nbsp;per&nbsp;minute）</strong>：目标吞吐量。注意这里是每分钟发送的请求数，因此，对应测试需求中所要求的20&nbsp;QPS&nbsp;，这里的值应该是1200&nbsp;。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;"><strong>Calculate&nbsp;Throughput&nbsp;based&nbsp;on&nbsp;</strong>：有5个选项，分别是：</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　This&nbsp;thread&nbsp;only&nbsp;：控制每个线程的吞吐量，选择这种模式时，总的吞吐量为设置的&nbsp;target&nbsp;Throughput&nbsp;乘以矣线程的数量。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　All&nbsp;active&nbsp;threads&nbsp;：&nbsp;设置的target&nbsp;Throughput&nbsp;将分配在每个活跃线程上，每个活跃线程在上一次运行结束后等待合理的时间后再次运行。活跃线程指同一时刻同时运行的线程。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　All&nbsp;active&nbsp;threads&nbsp;in&nbsp;current&nbsp;thread&nbsp;group&nbsp;：设置的target&nbsp;Throughput将分配在当前线程组的每一个活跃线程上，当测试计划中只有一个线程组时，该选项和All&nbsp;active&nbsp;threads选项的效果完全相同。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　All&nbsp;active&nbsp;threads&nbsp;（shared&nbsp;）：与All&nbsp;active&nbsp;threads&nbsp;的选项基本相同，唯一的区别是，每个活跃线程都会在所有活跃线程上一次运行结束后等待合理的时间后再次运行。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　All&nbsp;cative&nbsp;threads&nbsp;in&nbsp;current&nbsp;thread&nbsp;group&nbsp;（shared&nbsp;）：与All&nbsp;active&nbsp;threads&nbsp;in&nbsp;current&nbsp;thread&nbsp;group&nbsp;基本相同，唯一的区别是，每个活跃线程都会在所有活跃线程的上一次运行结束后等待合理的时间后再次运行。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　如上图，该元件仅作用于fnng.cnblogs.com&nbsp;，设置定时器的Target&nbsp;throughput为1200/分钟（20&nbsp;QPS），设置Calculate&nbsp;Throughput&nbsp;based&nbsp;on&nbsp;的值为All&nbsp;active&nbsp;threads&nbsp;。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　当然，Constant&nbsp;Throughput&nbsp;Timer只有在线程组中的线程产生足够多的request&nbsp;的情况下才有意义，因此，即使设置了Constant&nbsp;Throughput&nbsp;Timer的值，也可能由于线程组中的线程数量不够，或是定时器设置不合理等原因导致总体的QPS不能达到预期目标。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 18pt;"><strong>添加监听器（Listener）</strong></span></p><hr style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;" /><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;　　<span style="font-size: 15px;">脚本的主要部分设置完成后，需要通过某种方式获得性能测试中的测试结果，在本例中，我们关心的是请求的响应时间。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　Jmeter&nbsp;中使用监听器元件收集取样器记录的数据并以可视化的方式来呈现。Jmeter有各种不同的监听器类型，因为上HTTP请求，我们可在添加聚合报告，更为直观的查看测试结果。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　添加聚合报告，右键点击线程组，在弹的菜单（添加---&gt;监听器---&gt;聚合报告）中选择聚合报告。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;<img src="http://images.cnitblog.com/blog/311516/201212/22205555-016307f6ea914e8fb3ef4f456c4c1927.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 18pt;"><strong>运行脚本</strong></span></p><hr style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;" /><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">　　<span style="font-size: 15px;">添加完成聚合报告后，我们来运行脚本，稍后介绍聚合报告的参数。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">　　在运脚本之前，我们来查看一下，各个元件的参数设置：</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">---------------------------------------------------------------&nbsp;</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">线程组：</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">线程数：20</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">准备时长：&nbsp;10</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">循环次数：10</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">---------------------------------------------------------------&nbsp;&nbsp;</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">HTTP请求：</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">名称：fnng.cnblogs.com。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">服务器名称或IP&nbsp;：fnng.cnblogs.com</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">端口号：80&nbsp;</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">Implementation&nbsp;：&nbsp;java&nbsp;</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">协议：&nbsp;http</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">方法：&nbsp;GET</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">路径：/</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">---------------------------------------------------------------&nbsp;&nbsp;</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">常数吞吐量定时器：</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">Target&nbsp;throughput（in&nbsp;samples&nbsp;per&nbsp;minute）：1200.0</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">Calculate&nbsp;Throughput&nbsp;based&nbsp;on&nbsp;：All&nbsp;active&nbsp;threads</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">---------------------------------------------------------------&nbsp;&nbsp;</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">点击工具栏上的运行按钮，或者点击菜单栏&#8220;&nbsp;运行---&gt;启动&nbsp;&#8221;&nbsp;或者使用快捷键ctrl+r&nbsp;来运行程序。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 18pt;"><strong>聚合报告分析</strong></span></p><hr style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;" /><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">查看聚合报告的运行结果：</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://images.cnitblog.com/blog/311516/201212/22205813-28e16b18b5bd4aa8b2453ae936ed4daf.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><img src="http://images.cnitblog.com/blog/311516/201212/22205843-84c76626e4084c34bcfd2c490480c1fb.png" alt="" style="border: 0px;" /></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><span style="font-size: 15px;">&nbsp;OK!&nbsp;到此一次完整的性能测试结束，如果你从中有所收获，推荐一记~！</span></p><img src ="http://www.blogjava.net/qileilove/aggbug/410975.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-13 13:04 <a href="http://www.blogjava.net/qileilove/articles/410975.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用JMeter进行性能测试</title><link>http://www.blogjava.net/qileilove/articles/410925.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Wed, 12 Mar 2014 03:08:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410925.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410925.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410925.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410925.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410925.html</trackback:ping><description><![CDATA[<p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">Meter是Apache组织的开放源代码项目，它是功能和性能测试的工具，100%的用java实现，最新的版本是1.9.1，大家可以到<a href="http://jakarta.apache.org/jmeter/index.html" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit; vertical-align: baseline; color: #745285;">http://jakarta.apache.org/jmeter/index.html</a>下载源代码和查看相关文档。</p><h2>JMeter作用领域</h2><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">JMeter可以用于测试静态或者动态资源的性能（文件、Servlets、Perl脚本、java对象、数据库和查询、ftp服务器或者其他的资源）。JMeter用于模拟在服务器、网络或者其他对象上附加高负载以测试他们提供服务的受压能力，或者分析他们提供的服务在不同负载条件下的总性能情况。你可以用JMeter提供的图形化界面分析性能指标或者在高负载情况下测试服务器/脚本/对象的行为。</p><div style="margin: 10px 0px; border: 0px; outline: 0px; font-size: 12.727272033691406px; vertical-align: baseline; font-family: Arial, sans-serif; background-color: #cccccc; height: 1px; clear: both; line-height: 13.96363639831543px;"></div><p ibm-back-to-top"="" style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; clear: both; text-align: right; height: 21.81818199157715px; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;"><a href="https://www.ibm.com/developerworks/cn/java/l-jmeter/#ibm-pcon" style="margin: 0px; padding: 0px 0px 0px 16px; border-width: 0px; border-bottom-style: none; outline: 0px; font-size: inherit; vertical-align: baseline; color: #745285; opacity: 0.8; display: inline; text-decoration: none; line-height: 1.065em; font-weight: bold; background-image: url(https://1.www.s81c.com/i/v17/icons/ibm_sprite_arrow_blue_ON.png) !important; background-position: 0px -401px; background-repeat: no-repeat no-repeat;">回页首</a></p><h2>使用JMeter测试Web应用</h2><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">接下来的章节里，作者将详细的演示如何使用JMeter来测试Web应用的完整过程。</p><h3>2.1	测试环境</h3><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; margin-top: -2px !important; font-size: 1.166em !important;">作者使用了Tomcat作为Web服务器进行测试，被测试的内容是一个jsp文件和一个servlet，jsp文件调用JavaBean、打印相关信息，servlet接受用户参数、调用javabean、输出相关信息。详细的内容请参考作者提供的JMeter.war的内容。</p><h3>2.2	安装启动JMeter</h3><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; margin-top: -2px !important; font-size: 1.166em !important;">大家可以到通过http://apache.linuxforum.net/dist/jakarta/jmeter/binaries/jakarta-jmeter-1.9.1.zip下载JMeter的release版本，然后将下载的.zip文件解压缩到C:/JMeter（后面的文章中将使用%JMeter%来引用这个目录）目录下。</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">现在，请使用%JMeter%/bin下面的jmeter.bat批处理文件来启动JMeter的可视化界面，下面的工作都将在这个可视化界面界面上进行操作。下面的图片是JMeter的可视化界面的屏幕截图。</p><h5>图一： JMeter打开时的屏幕截图</h5><img alt="图一： JMeter打开时的屏幕截图" src="https://www.ibm.com/developerworks/cn/java/l-jmeter/images/image001.png" width="408" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 12.727272033691406px; vertical-align: baseline; font-family: Arial, sans-serif; line-height: 13.96363639831543px; background-color: #ffffff;" /><h3>2.3	建立测试计划（Test Plan）</h3><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; margin-top: -2px !important; font-size: 1.166em !important;">测试计划描述了执行测试过程中JMeter的执行过程和步骤，一个完整的测试计划包括一个或者多个线程组(Thread Groups)、逻辑控制（Logic Controller）、实例产生控制器（Sample Generating Controllers）、侦听器(Listener)、定时器（Timer）、比较（Assertions）、配置元素（Config Elements）。打开JMeter时，它已经建立一个默认的测试计划,一个JMeter应用的实例只能建立或者打开一个测试计划。</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">现在我们开始填充一个测试计划的内容，这个测试计划向一个jsp文件和一个servlet发出请求，我们需要JMeter模拟五个请求者（也就是五个线程），每个请求者连续请求两次，下面的章节介绍了详细的操作步骤。</p><h3>2.4	增加负载信息设置</h3><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; margin-top: -2px !important; font-size: 1.166em !important;">这一步，我们将向测试计划中增加相关负载设置,是Jmeter知道我们需要模拟五个请求者，每个请求者在测试过程中连续请求两次。详细步骤如下：</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">1.	选中可视化界面中左边树的Test Plan节点，单击右键，选择Add'Thread Group，界面右边将会出现他的设置信息框。</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">2.	Thread Group有三个和负载信息相关的参数：&nbsp;<br />Number of Threads： 设置发送请求的用户数目&nbsp;<br />Ramp-up period： 每个请求发生的总时间间隔，单位是秒。比如你的请求数目是5，而这个参数是10，那么每个请求之间的间隔就是10／5，也就是2秒&nbsp;<br />Loop Count： 请求发生的重复次数，如果选择后面的forever（默认），那么	 请求将一直继续，如果不选择forever，而在输入框中输入数字，那么请求将重复	 指定的次数，如果输入0，那么请求将执行一次。</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">根据我们演示例子的设计，我们应该将Number of Threads设置为5，Ramp-up period设置为0（也就是同时并发请求），不选中forever，在Loop Count后面的输入框中输入2，设置后的屏幕截图如下：</p><h5>图二：设置好参数的Thread Group。</h5><img alt="图二：设置好参数的Thread Group。" src="https://www.ibm.com/developerworks/cn/java/l-jmeter/images/image003.png" width="447" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 12.727272033691406px; vertical-align: baseline; font-family: Arial, sans-serif; line-height: 13.96363639831543px; background-color: #ffffff;" /><h3>2.5	增加默认Http属性（可选）</h3><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; margin-top: -2px !important; font-size: 1.166em !important;">实际的测试工作往往是针对同一个服务器上Web应用展开的,所以Jmeter提供了这样一种设置, 在默认Http属性设置需要被测试服务器的相关属性，以后的http请求设置中就可以忽略这些相同参数的设置,减少设置参数录入的时间。</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">我们这里将采用这种属性。你可以通过下面的步骤来设置默认http属性：</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">1.	选中可视化界面中左边树的Test Plan节点，单击右键，选择Add'config element'http request defaults，界面右边将会出现他的设置信息框。</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">2.	默认http属性的主要参数说明如下：&nbsp;<br />protocal：发送测试请求时使用的协议&nbsp;<br />server name or ip：被测试服务器的ip地址或者名字&nbsp;<br />path： 默认的起始位置。比如将path设置为／jmeter，那么所有的http请求的url中都将增加／jmeter路径。&nbsp;<br />port number： 服务器提供服务的端口号</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">我们的测试计划将针对本机的Web服务器上的Web应用进行测试，所以protocal应该是http，ip使用localhost，因为这个web应用发布的context路径是／jmeter，所以这里的path设置为／jmeter，因为使用Tomcat服务器，所以port number是8080。设置后的屏幕截图如下：</p><h5>图三： 测试计划中使用的默认Http参数</h5><img alt="图三： 测试计划中使用的默认Http参数" src="https://www.ibm.com/developerworks/cn/java/l-jmeter/images/image005.png" width="500" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 12.727272033691406px; vertical-align: baseline; font-family: Arial, sans-serif; line-height: 13.96363639831543px; background-color: #ffffff;" /><h3>2.6	增加Http请求</h3><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; margin-top: -2px !important; font-size: 1.166em !important;">现在我们需要增加http请求了，他也是我们测试的内容主体部分。你可以通过下面的步骤来增加性的http请求：</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">1.	选中可视化界面中左边树的Thread Group节点，单击右键，选择Add'sampler'http request，界面右边将会出现他的设置信息框。</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">2.	他的参数和2.5中介绍的http属性差不多，增加的属性中有发送http时方法的选择，你可以选择为get或者post。</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">我们现在增加两个http 请求，因为我们设置了默认的http属性，所以和默认http属性中相同的属性不再重复设置。设置后的屏幕截图如下：</p><h5>图四：设置好的jsp测试请求</h5><img alt="图四：设置好的jsp测试请求" src="https://www.ibm.com/developerworks/cn/java/l-jmeter/images/image007.png" width="506" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 12.727272033691406px; vertical-align: baseline; font-family: Arial, sans-serif; line-height: 13.96363639831543px; background-color: #ffffff;" /><h5>图五：设置好的Servlet测试请求（带参数）</h5><img alt="图五：设置好的Servlet测试请求（带参数）" src="https://www.ibm.com/developerworks/cn/java/l-jmeter/images/image009.png" width="505" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 12.727272033691406px; vertical-align: baseline; font-family: Arial, sans-serif; line-height: 13.96363639831543px; background-color: #ffffff;" /><h3>2.7	增加Listener</h3><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; margin-top: -2px !important; font-size: 1.166em !important;">增加listener是为了记录测试信息并且可以使用Jmeter提供的可视化界面查看测试结果，里面有好几种结果分析方式可供选择，你可以根据自己习惯的分析方式选择不同的结果显示方式，我们这里使用表格的形式来查看和分析测试结果。你可以通过下面的步骤来增加listener：</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">1.	选中可视化界面中左边树的Test Plan节点，单击右键，选择Add'listener'view result in table，界面右边将会出现他的设置信息和结果显示框。</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">2.	你可以设置界面上面的filename属性设置将测试结果保存到某个文件中 界面下面将使用表格显示测试结果，表格的第一列sampleno显示请求执行的顺序和编号，url显示请求发送的目标，sample－ms列显示这个请求完成耗费的时间，最后的success列显示改请求是否成功执行。</p><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">界面的最下面你还可以看到一些统计信息，最关心的应该是Average吧，也就是相应的平均时间。</p><h3>2.8	开始执行测试计划</h3><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; margin-top: -2px !important; font-size: 1.166em !important;">现在你可以通过单击菜单栏run -&gt; Start开始执行测试计划了。下面这两个图是作者第一次、第二次执行该测试计划的结果图:</p><h5>图六：第一次执行后的结果显示</h5><img alt="图六：第一次执行后的结果显示" src="https://www.ibm.com/developerworks/cn/java/l-jmeter/images/image011.png" width="564" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 12.727272033691406px; vertical-align: baseline; font-family: Arial, sans-serif; line-height: 13.96363639831543px; background-color: #ffffff;" /><h5>图七：第二次执行的结果显示</h5><img alt="图七：第二次执行的结果显示" src="https://www.ibm.com/developerworks/cn/java/l-jmeter/images/image013.png" width="564" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 12.727272033691406px; vertical-align: baseline; font-family: Arial, sans-serif; line-height: 13.96363639831543px; background-color: #ffffff;" /><p style="margin: 0px; padding: 6px 0px; border: 0px; outline: 0px; vertical-align: baseline; font-family: Arial, sans-serif; color: #222222; line-height: 1.5em; background-color: #ffffff; font-size: 1.166em !important;">大家可以看到第一次执行时的几个大时间值均来自于jsp request，这可以通过下面的理由进行解释：jsp执行前都需要被编译成.class文件。所以第二次的结果才是正常的结果。</p><div></div><img src ="http://www.blogjava.net/qileilove/aggbug/410925.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-12 11:08 <a href="http://www.blogjava.net/qileilove/articles/410925.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Jmeter + DadBoby 安装使用</title><link>http://www.blogjava.net/qileilove/articles/410917.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Wed, 12 Mar 2014 02:51:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410917.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410917.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410917.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410917.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410917.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">一直接触LR比较多，这阵子突然想了解一下开源的<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;"></strong></u></a><u style="word-break: break-all; line-height: normal !important;"><strong style="word-break: break-all;"><a target="_self" style="word-break: break-all; color: #202859; text-decoration: none;"><u style="word-break: break-all;"><strong style="word-break: break-all;">性能测试</strong></u></a>工具</strong></u>，无意中接触到了Jmeter+Badboy，这两款工具对于想进行性能测试，但又对LR高额的商业费用望而止步的小公司可谓是再适合不过了。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">自已小结一下：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">JMeter</strong></u></a>是纯Java编写的功能与性能测试工具，但其录制脚本过于笨拙复杂，成为使用者的诟病。Badboy是用C++开发的，被用于测试和开发复杂的动态应用。 它提供了强大的屏幕录制和回放功能，同时也提供了丰富的图形结果分析功能。只要不用于商业目的就可以免费使用。因此这两工具的结合，就成为了绝配。你可以 用Badboy录制脚本，然后将录制的脚本导出为JMeter格式的脚本，最后将该脚本导入到JMeter，借助于JMeter强大的测试功能模拟大量的 虚拟用户，进行复杂的性能测试。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　1. 安装Badboy</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　下载地址 http://badboy.com.au/download/index，按网页提示输入name/email/company等后下载标识为recommended的那个版本。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　这是一个可执行程序，下载之后双击，根据安装向导安装。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">2. 安装Jmeter</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　http://jmeter.apache.org/选择Download Releases --点击下载Binary: apache-jmeter-2.7_src.zip(注意zip包才是适合windows系统的，其中Source是可以看到源码的包，如果不需要查看源码可以只下载Binary下的zip包。)下载后解压;</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　安装Jmeter需本地安装JDK及配置好环境变量，详细配置如下：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　解压apache-jmeter-2.7_src.zip至C盘c:\apache-jmeter-2.7目录下，桌面选择&#8221;我的电脑&#8220;（右键）--高级--环境变量，在&#8221;系统变量&#8220;---&#8221;新建&#8220;，在变量名中输入：JMETER_HOME，变量值中输入：c:\apache-jmeter-2.7，再修改CLASSPATH变量，变量值中添加%JMETER_HOME%\lib\ext\ApacheJMeter_core.jar;%JMETER_HOME%\lib\jorphan.jar;%JMETER_HOME%\lib\logkit-2.0.jar; 然后确定。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　然后到Jmeter\bin下运行jmeter.bat即可打开Jmeter</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">3. 用Badboy录制脚本并到处为JMeter格式的脚本</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　在开始菜单中启用Badboy，点击工具栏上的红色圆饼按钮，开始录制，然后在URL框中输入你要测试站点的URL。随便点击几个链接，然后点击工具栏上的黑色方框按钮，停止录制。最后点击 File &#8211;&gt;Export to JMeter&#8230; ，将录制的脚本导出为Jmeter格式的脚本。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">4. 启用JMeter，导入Badboy录制的脚本，并设置测试计划，开始测试</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　然后点击 文件 &#8211;&gt;打开，在文件管理器中选择你刚导出的Badboy录制的脚本。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">Jmeter和LR一样有着录制脚本、参数化、检查点、集合点、设置关联、场景等。</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">1，Jmeter参数化：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　先准备一个dat文件保存在本地，然后选择&#8221;选项&#8220;---函数助手---__CSVRead--输入dat文件保存的路径如C:\test.dat，点击生成并复制${__CSVRead(c:\test.dat,)}</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　找到需参数化的页面--将复制的${__CSVRead(c:\test.dat,)}粘贴到参数化值的位置。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　2，检查点：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　检查对对象设置：右键点击某页面----&gt;添加----&gt;断言----&gt;响应断言</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　检查结果：添加一个断言结果，右键点击页面----&gt;添加----&gt;监听器----&gt;断言结果</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　还可以再添加一个&#8220;查看结果树&#8221; 右键点击我们的&#8220;登录&#8221;页面----&gt;添加----&gt;监听器----&gt;查看结果树</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">3，集合点设置：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　右键点击 step1----&gt;定时器----&gt;Synchronizing Timer，这样子就添加了一个&#8220;集合点&#8221;，如果发现集合点的位置不对，可发随需要插入到相应位置。<br /><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;"><strong style="word-break: break-all; line-height: normal !important;">　4，关联:</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　方法一，从前一个请求中取，用正则表达式提取器。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　具体方法，在需要获得数据的请求上右击添加一个后置处理器--&gt;正则表达式提取器</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　引用名称即下一个请求要引用的参数名称，如填写title，则可用${title}引用它。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　正则表达式中()括起来的部分就是要提取的。.代表任意字符，*代表出现任意次。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　模板，用$$引用起来，如果在正则表达式中有多个正则表达式（多个括号括起来的东东），则可以是$2$，$3$等等，表示解析到的第几个值给title。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　匹配数字，0代表随机，-1代表所有，其余正整数代表将在检查的内容中，第几个匹配的内容提取出来。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　方法二，用xpath从前一个请求中取。这种形式比较适合于返回为xml片段的情况。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　在需要获得数据的请求上右击添加一个后置处理器--&gt;xPath Extractor。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　引用名称即下一个请求要引用的参数名称，如填写body，则可用${body}引用它。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　XPath query，即xpath的表达式，要符合xpath的语法。</div></div><img src ="http://www.blogjava.net/qileilove/aggbug/410917.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-12 10:51 <a href="http://www.blogjava.net/qileilove/articles/410917.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jmeter之监听器</title><link>http://www.blogjava.net/qileilove/articles/410862.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Tue, 11 Mar 2014 03:46:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410862.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410862.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410862.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410862.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410862.html</trackback:ping><description><![CDATA[<table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Aggregate_Graph">18.3.12 Aggregate Graph</a></h3></td></tr><tr><td>The aggregate graph is similar to the aggregate report. The primary difference is the aggregate graph provides an easy way to generate bar graphs and save the graph as a PNG file.<p><strong>Control Panel</strong></p><div align="center"><img width="893" height="713" src="http://jmeter.apache.org/images/screenshots/aggregate_graph.png"  alt="" /></div><div align="center"><p>The figure below shows an example of settings to draw this graph.</p><p>&nbsp;</p><table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><img width="900" height="442" src="http://jmeter.apache.org/images/screenshots/aggregate_graph_settings.png"  alt="" /><br />Aggregate graph settings</td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p></div><p><em>Please note: All this parameters&nbsp;<strong>aren't&nbsp;</strong>saved in JMeter jmx script.</em></p><p><strong>Parameters</strong><a name="Aggregate_Graph_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Column settings</td><td><ul><li><u>Columns to display:&nbsp;</u>Choose the column(s) to display in graph.</li><li><u>Rectangles color:&nbsp;</u>Clic on right color rectangle open a popup dialog to choose a custom color for column.</li><li><u>Foreground color&nbsp;</u>Allow to change the value text color.</li><li><u>Value font:&nbsp;</u>Allow to define font settings for the text.</li><li><u>Draw outlines bar?&nbsp;</u>To draw or not the border line on bar chart</li><li><u>Show number grouping?&nbsp;</u>Show or not the number grouping in Y Axis labels.</li><li><u>Value labels vertical?&nbsp;</u>Change orientation for value label. (Default is horizontal)</li><li><u>Column label selection:&nbsp;</u>Filter by result label. A regular expression can be used, example:&nbsp;<em>.*Transaction.*&nbsp;</em><br />Before display the graph, click on&nbsp;<strong>Apply filter&nbsp;</strong>button to refresh internal data.</li></ul></td><td>Yes</td></tr><tr><td>Title</td><td>Define the graph's title on the head of chart. Empty value is the default value : "Aggregate Graph". The button&nbsp;<strong>Synchronize with name&nbsp;</strong>define the title with the label of the listener. And define font settings for graph title</td><td>No</td></tr><tr><td>Graph size</td><td>Compute the graph size by the width and height depending of the current JMeter's window size. Use Width and Height fields to define a custom size. The unit is pixel.</td><td>No</td></tr><tr><td>X Axis settings</td><td>Define the max length of X Axis label (in pixel).</td><td>No</td></tr><tr><td>Y Axis settings</td><td>Define a custom maximum value for Y Axis.</td><td>No</td></tr><tr><td>Legend</td><td>Define the placement and font settings for chart legend</td><td>Yes</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="BeanShell_Listener">18.3.15 BeanShell Listener</a></h3></td></tr><tr><td><p>The BeanShell Listener allows the use of BeanShell for processing samples for saving etc.</p><p><strong>For full details on using BeanShell, please see the&nbsp;<a href="http://www.beanshell.org/">BeanShell website.</a></strong></p><p>The test element supports the ThreadListener and TestListener methods. These should be defined in the initialisation file. See the file BeanShellListeners.bshrc for example definitions.</p><p><strong>Control Panel</strong></p><div align="center"><img width="844" height="633" src="http://jmeter.apache.org/images/screenshots/beanshell_listener.png"  alt="" /></div><p><strong>Parameters</strong><a name="BeanShell_Listener_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree. The name is stored in the script variable Label</td><td>No</td></tr><tr><td>Reset bsh.Interpreter before each call</td><td>If this option is selected, then the interpreter will be recreated for each sample. This may be necessary for some long running scripts. For further information, see&nbsp;<a href="http://jmeter.apache.org/usermanual/best-practices#bsh_scripting">Best Practices - BeanShell scripting&nbsp;</a>.</td><td>Yes</td></tr><tr><td>Parameters</td><td>Parameters to pass to the BeanShell script. The parameters are stored in the following variables:<ul><li>Parameters - string containing the parameters as a single variable</li><li>bsh.args - String array containing parameters, split on white-space</li></ul></td><td>No</td></tr><tr><td>Script file</td><td>A file containing the BeanShell script to run. The file name is stored in the script variable FileName</td><td>No</td></tr><tr><td>Script</td><td>The BeanShell script to run. The return value is ignored.</td><td>Yes (unless script file is provided)</td></tr></tbody></table><p>&nbsp;</p><p>Before invoking the script, some variables are set up in the BeanShell interpreter:</p><ul><li>log - (Logger) - can be used to write to the log file</li><li>ctx - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html">JMeterContext&nbsp;</a>) - gives access to the context</li><li>vars - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html">JMeterVariables&nbsp;</a>) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object());</li><li>props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");</li><li>sampleResult, prev - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html">SampleResult&nbsp;</a>) - gives access to the previous&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html">SampleResult</a></li><li>sampleEvent (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleEvent.html">SampleEvent&nbsp;</a>) gives access to the current sample event</li></ul><p>For details of all the methods available on each of the above variables, please check the Javadoc</p><p>If the property&nbsp;<strong>beanshell.listener.init&nbsp;</strong>is defined, this is used to load an initialisation file, which can be used to define methods etc for use in the BeanShell script.</p></td></tr></tbody></table><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="BSF_Listener">18.3.18 BSF Listener</a></h3></td></tr><tr><td><p>The BSF Listener allows BSF script code to be applied to sample results.</p><p><strong>Control Panel</strong></p><div align="center"><img width="847" height="634" src="http://jmeter.apache.org/images/screenshots/bsf_listener.png"  alt="" /></div><p><strong>Parameters</strong><a name="BSF_Listener_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Language</td><td>The BSF language to be used</td><td>Yes</td></tr><tr><td>Parameters</td><td>Parameters to pass to the script. The parameters are stored in the following variables:<ul><li>Parameters - string containing the parameters as a single variable</li><li>args - String array containing parameters, split on white-space</li></ul></td><td>No</td></tr><tr><td>Script file</td><td>A file containing the script to run, if a relative file path is used, then it will be relative to directory referenced by "user.dir" System property</td><td>No</td></tr><tr><td>Script</td><td>The script to run.</td><td>Yes (unless script file is provided)</td></tr></tbody></table><p>&nbsp;</p><p>The script (or file) is processed using the BSFEngine.exec() method, which does not return a value.</p><p>Before invoking the script, some variables are set up. Note that these are BSF variables - i.e. they can be used directly in the script.</p><ul><li>log - (Logger) - can be used to write to the log file</li><li>Label - the String Label</li><li>Filename - the script file name (if any)</li><li>Parameters - the parameters (as a String)</li><li>args[] - the parameters as a String array (split on whitespace)</li><li>ctx - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html">JMeterContext&nbsp;</a>) - gives access to the context</li><li>vars - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html">JMeterVariables&nbsp;</a>) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object()); vars.getObject("OBJ2");</li><li>props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");</li><li>sampleResult, prev - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html">SampleResult&nbsp;</a>) - gives access to the SampleResult</li><li>sampleEvent - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleEvent.html">SampleEvent&nbsp;</a>) - gives access to the SampleEvent</li><li>sampler - (Sampler)- gives access to the last sampler</li><li>OUT - System.out - e.g. OUT.println("message")</li></ul><p>For details of all the methods available on each of the above variables, please check the Javadoc</p></td></tr><tr></tr></tbody></table><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Comparison_Assertion_Visualizer">18.3.20 Comparison Assertion Visualizer</a></h3></td></tr><tr><td>The Comparison Assertion Visualizer shows the results of any&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#Compare_Assertion">Compare Assertion</a>&nbsp;elements.<p><strong>Control Panel</strong></p><div align="center"><img width="777" height="266" src="http://jmeter.apache.org/images/screenshots/comparison_assertion_visualizer.png"  alt="" /></div><p><strong>Parameters</strong><a name="Comparison_Assertion_Visualizer_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>Yes</td></tr></tbody></table></td></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Distribution_Graph_(alpha)">18.3.11 Distribution Graph (alpha)</a></h3></td></tr><tr><td><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>Distribution Graph MUST NOT BE USED during load test as it consumes a lot of resources (memory and CPU). Use it only for either functional testing or during Test Plan debugging and Validation.</td></tr></tbody></table><p>&nbsp;</p><p>The distribution graph will display a bar for every unique response time. Since the granularity of System.currentTimeMillis() is 10 milliseconds, the 90% threshold should be within the width of the graph. The graph will draw two threshold lines: 50% and 90%. What this means is 50% of the response times finished between 0 and the line. The same is true of 90% line. Several tests with Tomcat were performed using 30 threads for 600K requests. The graph was able to display the distribution without any problems and both the 50% and 90% line were within the width of the graph. A performant application will generally produce results that clump together. A poorly written application that has memory leaks may result in wild fluctuations. In those situations, the threshold lines may be beyond the width of the graph. The recommended solution to this specific problem is fix the webapp so it performs well. If your test plan produces distribution graphs with no apparent clumping or pattern, it may indicate a memory leak. The only way to know for sure is to use a profiling tool.</p><p><strong>Control Panel</strong></p><div align="center"><img width="819" height="626" src="http://jmeter.apache.org/images/screenshots/distribution_graph.png"  alt="" /></div></td></tr><tr><td><br /></td></tr></tbody></table><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Response_Time_Graph">18.3.13 Response Time Graph</a></h3></td></tr><tr><td>The Response Time Graph draws a line chart showing the evolution of response time during the test, for each labelled request. If many samples exist for the same timestamp, the mean value is displayed.<p><strong>Control Panel</strong></p><div align="center"><img width="921" height="616" src="http://jmeter.apache.org/images/screenshots/response_time_graph.png"  alt="" /></div><div align="center"><p>The figure below shows an example of settings to draw this graph.</p><p>&nbsp;</p><table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><img width="919" height="481" src="http://jmeter.apache.org/images/screenshots/response_time_graph_settings.png"  alt="" /><br />Response time graph settings</td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p></div><p><em>Please note: All this parameters&nbsp;<strong>aren't&nbsp;</strong>saved in JMeter jmx script.</em></p><p><strong>Parameters</strong><a name="Response_Time_Graph_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Interval (ms)</td><td>The time in milli-seconds for X axis interval. Samples are grouped according to this value. Before display the graph, click on<strong>Apply interval&nbsp;</strong>button to refresh internal data.</td><td>Yes</td></tr><tr><td>Sampler label selection</td><td>Filter by result label. A regular expression can be used, ex.&nbsp;<em>.*Transaction.*&nbsp;</em>. Before display the graph, click on&nbsp;<strong>Apply filter</strong>button to refresh internal data.</td><td>No</td></tr><tr><td>Title</td><td>Define the graph's title on the head of chart. Empty value is the default value : "Response Time Graph". The button&nbsp;<strong>Synchronize with name&nbsp;</strong>define the title with the label of the listener. And define font settings for graph title</td><td>No</td></tr><tr><td>Line settings</td><td>Define the width of the line. Define the type of each value point. Choose&nbsp;<em>none&nbsp;</em>to have a line without mark</td><td>Yes</td></tr><tr><td>Graph size</td><td>Compute the graph size by the width and height depending of the current JMeter's window size. Use Width and Height fields to define a custom size. The unit is pixel.</td><td>No</td></tr><tr><td>X Axis settings</td><td>Customize the date format of X axis label. The syntax is the Java&nbsp;<a href="http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat API&nbsp;</a>.</td><td>No</td></tr><tr><td>Y Axis settings</td><td>Define a custom maximum value for Y Axis in milli-seconds. Define the increment for the scale (in ms) Show or not the number grouping in Y Axis labels.</td><td>No</td></tr><tr><td>Legend</td><td>Define the placement and font settings for chart legend</td><td>Yes</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Simple_Data_Writer">18.3.9 Simple Data Writer</a></h3></td></tr><tr><td>This listener can record results to a file but not to the UI. It is meant to provide an efficient means of recording data by eliminating GUI overhead. When running in non-GUI mode, the -l flag can be used to create a data file. The fields to save are defined by JMeter properties. See the jmeter.properties file for details.<p><strong>Control Panel</strong></p><div align="center"><img width="741" height="141" src="http://jmeter.apache.org/images/screenshots/simpledatawriter.png"  alt="" /></div></td></tr><tr></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Spline_Visualizer">18.3.4 Spline Visualizer</a></h3></td></tr><tr><td><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>Spline Visualizer MUST NOT BE USED during load test as it consumes a lot of resources (memory and CPU). Use it only for either functional testing or during Test Plan debugging and Validation.</td></tr></tbody></table><p>&nbsp;</p><p>The Spline Visualizer provides a view of all sample times from the start of the test till the end, regardless of how many samples have been taken. The spline has 10 points, each representing 10% of the samples, and connected using spline logic to show a single continuous line.</p><p>The graph is automatically scaled to fit within the window. This needs to be borne in mind when comparing graphs.</p><p><strong>Control Panel</strong></p><div align="center"><img width="581" height="440" src="http://jmeter.apache.org/images/screenshots/spline_visualizer.png"  alt="" /></div></td></tr></tbody></table><br /><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Summary_Report">8.3.16 Summary Report</a></h3></td></tr><tr><td>The summary report creates a table row for each differently named request in your test. This is similar to the&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#Aggregate_Report">Aggregate Report</a>&nbsp;, except that it uses less memory.<p>The thoughput is calculated from the point of view of the sampler target (e.g. the remote server in the case of HTTP samples). JMeter takes into account the total time over which the requests have been generated. If other samplers and timers are in the same thread, these will increase the total time, and therefore reduce the throughput value. So two identical samplers with different names will have half the throughput of two samplers with the same name. It is important to choose the sampler labels correctly to get the best results from the Report.</p><ul><li>Label - The label of the sample. If "Include group name in label?" is selected, then the name of the thread group is added as a prefix. This allows identical labels from different thread groups to be collated separately if required.</li><li># Samples - The number of samples with the same label</li><li>Average - The average elapsed time of a set of results</li><li>Min - The lowest elapsed time for the samples with the same label</li><li>Max - The longest elapsed time for the samples with the same label</li><li>Std. Dev. - the&nbsp;<a href="http://jmeter.apache.org/usermanual/glossary.html#StandardDeviation">Standard Deviation&nbsp;</a>of the sample elapsed time</li><li>Error % - Percent of requests with errors</li><li>Throughput - the&nbsp;<a href="http://jmeter.apache.org/usermanual/glossary.html#Throughput">Throughput&nbsp;</a>is measured in requests per second/minute/hour. The time unit is chosen so that the displayed rate is at least 1.0. When the throughput is saved to a CSV file, it is expressed in requests/second, i.e. 30.0 requests/minute is saved as 0.5.</li><li>Kb/sec - The throughput measured in Kilobytes per second</li><li>Avg. Bytes - average size of the sample response in bytes. (in JMeter 2.2 it wrongly showed the value in kB)</li></ul><p>Times are in milliseconds.</p><p><strong>Control Panel</strong></p><div align="center"><img width="784" height="287" src="http://jmeter.apache.org/images/screenshots/summary_report.png"  alt="" /></div><div align="center"><p>The figure below shows an example of selecting the "Include group name" checkbox.</p><p>&nbsp;</p><table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><img width="784" height="287" src="http://jmeter.apache.org/images/screenshots/summary_report_grouped.png"  alt="" /><br />Sample "Include group name" display</td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p></div></td></tr><tr></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Save_Responses_to_a_file">18.3.17 Save Responses to a file</a></h3></td></tr><tr><td><p>This test element can be placed anywhere in the test plan. For each sample in its scope, it will create a file of the response Data. The primary use for this is in creating functional tests, but it can also be useful where the response is too large to be displayed in the&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#View_Results_Tree">View Results Tree</a>&nbsp;Listener. The file name is created from the specified prefix, plus a number (unless this is disabled, see below). The file extension is created from the document type, if known. If not known, the file extension is set to 'unknown'. If numbering is disabled, and adding a suffix is disabled, then the file prefix is taken as the entire file name. This allows a fixed file name to be generated if required. The generated file name is stored in the sample response, and can be saved in the test log output file if required.</p><p>The current sample is saved first, followed by any sub-samples (child samples). If a variable name is provided, then the names of the files are saved in the order that the sub-samples appear. See below.</p><p><strong>Control Panel</strong></p><div align="center"><img width="358" height="225" src="http://jmeter.apache.org/images/screenshots/savetofile.png"  alt="" /></div><p><strong>Parameters</strong><a name="Save_Responses_to_a_file_parms" style="width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat;"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Filename Prefix</td><td>Prefix for the generated file names; this can include a directory name. Relative paths are resolved relative to the current working directory (which defaults to the bin/ directory). Versions of JMeter after 2.4 also support paths relative to the directory containing the current test plan (JMX file). If the path name begins with "~/" (or whatever is in the jmeter.save.saveservice.base_prefix JMeter property), then the path is assumed to be relative to the JMX file location.</td><td>Yes</td></tr><tr><td>Variable Name</td><td>Name of a variable in which to save the generated file name (so it can be used later in the test plan). If there are sub-samples then a numeric suffix is added to the variable name. E.g. if the variable name is FILENAME, then the parent sample file name is saved in the variable FILENAME, and the filenames for the child samplers are saved in FILENAME1, FILENAME2 etc.</td><td>No</td></tr><tr><td>Save Failed Responses only</td><td>If selected, then only failed responses are saved</td><td>Yes</td></tr><tr><td>Save Successful Responses only</td><td>If selected, then only successful responses are saved</td><td>Yes</td></tr><tr><td>Don't add number to prefix</td><td>If selected, then no number is added to the prefix. If you select this option, make sure that the prefix is unique or the file may be overwritten.</td><td>Yes</td></tr><tr><td>Don't add suffix</td><td>If selected, then no suffix is added. If you select this option, make sure that the prefix is unique or the file may be overwritten.</td><td>Yes</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr><td><br /><br /><br /><br /></td></tr></tbody></table><br /><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Graph_Results">18.3.3 Graph Results</a></h3></td></tr><tr><td><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>Graph Results MUST NOT BE USED during load test as it consumes a lot of resources (memory and CPU). Use it only for either functional testing or during Test Plan debugging and Validation.</td></tr></tbody></table><p>&nbsp;</p><p>The Graph Results listener generates a simple graph that plots all sample times. Along the bottom of the graph, the current sample (black), the current average of all samples(blue), the current standard deviation (red), and the current throughput rate (green) are displayed in milliseconds.</p><p>The throughput number represents the actual number of requests/minute the server handled. This calculation includes any delays you added to your test and JMeter's own internal processing time. The advantage of doing the calculation like this is that this number represents something real - your server in fact handled that many requests per minute, and you can increase the number of threads and/or decrease the delays to discover your server's maximum throughput. Whereas if you made calculations that factored out delays and JMeter's processing, it would be unclear what you could conclude from that number.</p><p><strong>Control Panel</strong></p><div align="center"><img width="915" height="686" src="http://jmeter.apache.org/images/screenshots/graph_results.png"  alt="" /></div><p>The following table briefly describes the items on the graph. Further details on the precise meaning of the statistical terms can be found on the web - e.g. Wikipedia - or by consulting a book on statistics.</p><ul><li>Data - plot the actual data values</li><li>Average - plot the Average</li><li>Median - plot the&nbsp;<a href="http://jmeter.apache.org/usermanual/glossary.html#Median">Median&nbsp;</a>(midway value)</li><li>Deviation - plot the&nbsp;<a href="http://jmeter.apache.org/usermanual/glossary.html#StandardDeviation">Standard Deviation&nbsp;</a>(a measure of the variation)</li><li>Throughput - plot the number of samples per unit of time</li></ul><p>The individual figures at the bottom of the display are the current values. "Latest Sample" is the current elapsed sample time, shown on the graph as "Data".</p></td></tr><tr><td><br /></td></tr></tbody></table><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Assertion_Results">18.3.5 Assertion Results</a></h3></td></tr><tr><td><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>Assertion Results MUST NOT BE USED during load test as it consumes a lot of resources (memory and CPU). Use it only for either functional testing or during Test Plan debugging and Validation.</td></tr></tbody></table><p>&nbsp;</p><p>The Assertion Results visualizer shows the Label of each sample taken. It also reports failures of any&nbsp;<a href="http://jmeter.apache.org/usermanual/test_plan.html#assertions">Assertions&nbsp;</a>that are part of the test plan.</p><p><strong>Control Panel</strong></p><div align="center"><img width="658" height="277" src="http://jmeter.apache.org/images/screenshots/assertion_results.png"  alt="" /></div><p><strong>See Also:</strong></p><ul><li><a href="http://jmeter.apache.org/usermanual/component_reference.html#Response_Assertion">Response Assertion</a></li></ul><p>&nbsp;</p></td></tr><tr></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Generate_Summary_Results">18.3.19 Generate Summary Results</a></h3></td></tr><tr><td>This test element can be placed anywhere in the test plan. Generates a summary of the test run so far to the log file and/or standard output. Both running and differential totals are shown. Output is generated every n seconds (default 3 minutes) on the appropriate time boundary, so that multiple test runs on the same time will be synchronised. See jmeter.properties file for the summariser configuration items:<pre># Define the following property to automatically start a summariser with that name # (applies to non-GUI mode only) #summariser.name=summary # # interval between summaries (in seconds) default 3 minutes #summariser.interval=180 # # Write messages to log file #summariser.log=true # # Write messages to System.out #summariser.out=true  </pre>This element is mainly intended for batch (non-GUI) runs. The output looks like the following:<pre>label +   171 in  20.3s =    8.4/s Avg:  1129 Min:  1000 Max:  1250 Err:     0 (0.00%) label +   263 in  31.3s =    8.4/s Avg:  1138 Min:  1000 Max:  1250 Err:     0 (0.00%) label =   434 in  50.4s =    8.6/s Avg:  1135 Min:  1000 Max:  1250 Err:     0 (0.00%) label +   263 in  31.0s =    8.5/s Avg:  1138 Min:  1000 Max:  1250 Err:     0 (0.00%) label =   697 in  80.3s =    8.7/s Avg:  1136 Min:  1000 Max:  1250 Err:     0 (0.00%) label +   109 in  12.4s =    8.8/s Avg:  1092 Min:    47 Max:  1250 Err:     0 (0.00%) label =   806 in  91.6s =    8.8/s Avg:  1130 Min:    47 Max:  1250 Err:     0 (0.00%)  </pre>The "label" is the the name of the element. The "+" means that the line is a delta line, i.e. shows the changes since the last output. The "=" means that the line is a totals line, i.e. it shows the running total. Entries in the jmeter log file also include time-stamps. The example "806 in 91.6s = 8.8/s" means that there were 806 samples recorded in 91.6 seconds, and that works out at 8.8 samples per second. The Avg (Average), Min(imum) and Max(imum) times are in milliseconds. "Err" means number of errors (also shown as percentage). The last two lines will appear at the end of a test. They will not be synchronised to the appropriate time boundary. Note that the initial and final deltas may be for less than the interval (in the example above this is 30 seconds). The first delta will generally be lower, as JMeter synchronises to the interval boundary. The last delta will be lower, as the test will generally not finish on an exact interval boundary.<p>The label is used to group sample results together. So if you have multiple Thread Groups and want to summarize across them all, then use the same label - or add the summariser to the Test Plan (so all thread groups are in scope). Different summary groupings can be implemented by using suitable labels and adding the summarisers to appropriate parts of the test plan.</p><p><strong>Control Panel</strong></p><div align="center"><img width="358" height="131" src="http://jmeter.apache.org/images/screenshots/summary.png"  alt="" /></div><p><strong>Parameters</strong><a name="Generate_Summary_Results_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree. It appears as the "label" in the output. Details for all elements with the same label will be added together.</td><td>Yes</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="View_Results_in_Table">18.3.8 View Results in Table</a></h3></td></tr><tr><td>This visualizer creates a row for every sample result. Like the&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#View_Results_Tree">View Results Tree</a>&nbsp;, this visualizer uses a lot of memory.<p>By default, it only displays the main (parent) samples; it does not display the sub-samples (child samples). Versions of JMeter after 2.5.1 have a "Child Samples?" check-box. If this is selected, then the sub-samples are displayed instead of the main samples.</p><p><strong>Control Panel</strong></p><div align="center"><img width="966" height="683" src="http://jmeter.apache.org/images/screenshots/table_results.png"  alt="" /></div></td></tr><tr><td><br /></td></tr></tbody></table><hr style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Monitor_Results">18.3.10 Monitor Results</a></h3></td></tr><tr><td><p>Monitor Results is a new Visualizer for displaying server status. It is designed for Tomcat 5, but any servlet container can port the status servlet and use this monitor. There are two primary tabs for the monitor. The first is the "Health" tab, which will show the status of one or more servers. The second tab labled "Performance" shows the performance for one server for the last 1000 samples. The equations used for the load calculation is included in the Visualizer.</p><p>Currently, the primary limitation of the monitor is system memory. A quick benchmark of memory usage indicates a buffer of 1000 data points for 100 servers would take roughly 10Mb of RAM. On a 1.4Ghz centrino laptop with 1Gb of ram, the monitor should be able to handle several hundred servers.</p><p>As a general rule, monitoring production systems should take care to set an appropriate interval. Intervals shorter than 5 seconds are too aggressive and have a potential of impacting the server. With a buffer of 1000 data points at 5 second intervals, the monitor would check the server status 12 times a minute or 720 times a hour. This means the buffer shows the performance history of each machine for the last hour.</p><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>The monitor requires Tomcat 5 or above. Use a browser to check that you can access the Tomcat status servlet OK.</td></tr></tbody></table><p>&nbsp;</p><p>For a detailed description of how to use the monitor, please refer to&nbsp;<a href="http://jmeter.apache.org/usermanual/build-monitor-test-plan.html">Building a Monitor Test Plan</a></p><p><strong>Control Panel</strong></p><div align="center"><img width="762" height="757" src="http://jmeter.apache.org/images/screenshots/monitor_screencap.png"  alt="" /></div></td></tr><tr></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Aggregate_Report">8.3.7 Aggregate Report</a></h3></td></tr><tr><td>The aggregate report creates a table row for each differently named request in your test. For each request, it totals the response information and provides request count, min, max, average, error rate, approximate throughput (request/second) and Kilobytes per second throughput. Once the test is done, the throughput is the actual through for the duration of the entire test.<p>The thoughput is calculated from the point of view of the sampler target (e.g. the remote server in the case of HTTP samples). JMeter takes into account the total time over which the requests have been generated. If other samplers and timers are in the same thread, these will increase the total time, and therefore reduce the throughput value. So two identical samplers with different names will have half the throughput of two samplers with the same name. It is important to choose the sampler names correctly to get the best results from the Aggregate Report.</p><p>Calculation of the&nbsp;<a href="http://jmeter.apache.org/usermanual/glossary.html#Median">Median&nbsp;</a>and 90% Line (90&nbsp;<sup>th&nbsp;</sup><a href="http://jmeter.apache.org/usermanual/glossary.html#Percentile">percentile&nbsp;</a>) values requires additional memory. For JMeter 2.3.4 and earlier, details of each sample were saved separately, which meant a lot of memory was needed. JMeter now combines samples with the same elapsed time, so far less memory is used. However, for samples that take more than a few seconds, the probability is that fewer samples will have identical times, in which case more memory will be needed. See the&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#Summary_Report">Summary Report</a>&nbsp;for a similar Listener that does not store individual samples and so needs constant memory.</p><ul><li>Label - The label of the sample. If "Include group name in label?" is selected, then the name of the thread group is added as a prefix. This allows identical labels from different thread groups to be collated separately if required.</li><li># Samples - The number of samples with the same label</li><li>Average - The average time of a set of results</li><li>Median - The&nbsp;<a href="http://jmeter.apache.org/usermanual/glossary.html#Median">median&nbsp;</a>is the time in the middle of a set of results. 50% of the samples took no more than this time; the remainder took at least as long.</li><li>90% Line - 90% of the samples took no more than this time. The remaining samples at least as long as this. (90&nbsp;<sup>th&nbsp;</sup><a href="http://jmeter.apache.org/usermanual/glossary.html#Percentile">percentile&nbsp;</a>)</li><li>Min - The shortest time for the samples with the same label</li><li>Max - The longest time for the samples with the same label</li><li>Error % - Percent of requests with errors</li><li>Throughput - the&nbsp;<a href="http://jmeter.apache.org/usermanual/glossary.html#Throughput">Throughput&nbsp;</a>is measured in requests per second/minute/hour. The time unit is chosen so that the displayed rate is at least 1.0. When the throughput is saved to a CSV file, it is expressed in requests/second, i.e. 30.0 requests/minute is saved as 0.5.</li><li>Kb/sec - The throughput measured in Kilobytes per second</li></ul><p>Times are in milliseconds.</p><p><strong>Control Panel</strong></p><div align="center"><img width="784" height="287" src="http://jmeter.apache.org/images/screenshots/aggregate_report.png"  alt="" /></div><div align="center"><p>The figure below shows an example of selecting the "Include group name" checkbox.</p><p>&nbsp;</p><table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><img width="784" height="287" src="http://jmeter.apache.org/images/screenshots/aggregate_report_grouped.png"  alt="" /><br />Sample "Include group name" display</td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p></div></td></tr><tr></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Mailer_Visualizer">18.3.14 Mailer Visualizer</a></h3></td></tr><tr><td><p>The mailer visualizer can be set up to send email if a test run receives too many failed responses from the server.</p><p><strong>Control Panel</strong></p><div align="center"><img width="860" height="403" src="http://jmeter.apache.org/images/screenshots/mailervisualizer.png"  alt="" /></div><p><strong>Parameters</strong><a name="Mailer_Visualizer_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>From</td><td>Email address to send messages from.</td><td>Yes</td></tr><tr><td>Addressee(s)</td><td>Email address to send messages to, comma-separated.</td><td>Yes</td></tr><tr><td>Success Subject</td><td>Email subject line for success messages.</td><td>No</td></tr><tr><td>Success Limit</td><td>Once this number of successful responses is exceeded&nbsp;<strong>after previously reaching the failure limit&nbsp;</strong>, a success email is sent. The mailer will thus only send out messages in a sequence of failed-succeeded-failed-succeeded, etc.</td><td>Yes</td></tr><tr><td>Failure Subject</td><td>Email subject line for fail messages.</td><td>No</td></tr><tr><td>Failure Limit</td><td>Once this number of failed responses is exceeded, a failure email is sent - i.e. set the count to 0 to send an e-mail on the first failure.</td><td>Yes</td></tr><tr><td>Host</td><td>IP address or host name of SMTP server (email redirector) server.</td><td>No</td></tr><tr><td>Port</td><td>Port of SMTP server (defaults to 25).</td><td>No</td></tr><tr><td>Login</td><td>Login used to authenticate.</td><td>No</td></tr><tr><td>Password</td><td>Password used to authenticate.</td><td>No</td></tr><tr><td>Connection security</td><td>Type of encryption for SMTP authentication (SSL, TLS or none).</td><td>No</td></tr><tr><td>Test Mail</td><td>Press this button to send a test mail</td><td>No</td></tr><tr><td>Failures</td><td>A field that keeps a running total of number of failures so far received.</td><td>No</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr></tr></tbody></table><img src ="http://www.blogjava.net/qileilove/aggbug/410862.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-11 11:46 <a href="http://www.blogjava.net/qileilove/articles/410862.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JMeter 聚合报告之90% Line参数说明</title><link>http://www.blogjava.net/qileilove/articles/410807.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Mon, 10 Mar 2014 03:11:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410807.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410807.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410807.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410807.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410807.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">其实要说明这个参数的含义非常简单，可能你早就知道他的含义，但我对这个参数一直有误解，而且还一直以为是&#8220;真理&#8221;，原于一次<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">面试</strong></u></a>，被问到了这个问题，所以引起我这个参数的重新认识。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">先说说我错误的认识：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　我一直把90%Line 理解为: 90%用户的平均响应时间。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　假如有10个数：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　1、2、3、4、5、6、7、8、9、23</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　我会从这一组数中剔除掉10%的&#8220;另类&#8221;，也就是剔除 23 ，因为如果把23计算进去求平均值，会有很大误差。可能大部分（90%）用户的响应感知那么差。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　如果计算所有用户的平均响应时间为：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　(1+2+3+4+5+6+7+8+9+23)/10=6.8 &nbsp;以秒单位的话，就是用户平均响应时间为6.8秒。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　去掉%10的另类（23）再来计算平均响应时间：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　(1+2+3+4+5+6+7+8+9)/9=5 &nbsp; 以秒为单位，那么90%用户的平均响应时间是5秒。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　那么，假如是下面的两组数呢：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　1、2、3、4、5、6、7、8、9、10</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　5、5、5、5、5、6、6、6、6、6</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　我求90%的平均响应时间，应该去哪个数？好像没有太突出的&#8220;另类&#8221;数。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　为什么会产生这个错误认识，因为看到不少资料（非官网）对&#8220;90%Line&#8221;解释为：90％ 用户的响应时间</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　90% Line 参数正确的含义：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　虽然，我的上面理解有一定的道理，显然它是错误的。那看看JMeter 官网是怎么说的？</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　90% Line - 90% of the samples took no more than this time. The remaining samples at least as long as this.</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　&#8220; 90% 的样品没有超过这个时间，剩余的样品至少只要这个。&#8221;（拿google翻译的）</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　没太理解是什么意思，于是，点击详细解释。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　90% Line (90 th Percentile) is the value below which 90% of the samples fall. The remaining samples too at least as long as the value. This is a standard statistical measure. See, for example: Percentile entry at Wikipedia.</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　英语太差，还是没理解到底啥意思，不过最后提示我，用维基百科查一下什么是百分位数。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">百分位数：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　统计学术语，如果将一组数据从大到小排序，并计算相应的累计百分位，则某一百分位所对应数据的值就称为这一百分位的百分位数。可表示为：一组n个观测值按数值大小排列如，处于p%位置的值称第p百分位数。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　中位数是第50百分位数。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　第25百分位数又称第一个四分位数（First Quartile）,用Q1表示；第50百分位数又称第二个四分位数（Second Quartile），用Q2表示；第75百分位数又称第三个四分位数（Third Quartile）,用Q3表示。若求得第p百分位数为小数，可完整为整数。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　分位数是用于衡量数据的位置的量度，但它所衡量的，不一定是中心位置。百分位数提供了有关各数据项如何在最小值与最大值之间分布的信息。对于无大量重复的数据，第p百分位数将它分为两个部分。大约有p%的数据项的值比第p百分位数小；而大约有(100－p)％的数据项的值比第p百分位数大。对第p百分位数，严格的定义如下。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　第p百分位数是这样一个值，它使得至少有p％的数据项小于或等于这个值，且至少有(100－p)％的数据项大于或等于这个值。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　高等院校的入学考试成绩经常以百分位数的形式报告。比如，假设某个考生在入学考试中的语文部分的原始分数为54分。相对于参加同一考试的其他学生来说，他的成绩如何并不容易知道。但是如果原始分数54分恰好对应的是第70百分位数，我们就能知道大约70％的学生的考分比他低，而约30％的学生考分比他高。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　其实，也就是最后这个考生分数的例子，让我豁然明白了。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　假如：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　有10个数：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　1、2、3、4、5、6、7、8、9、10 &nbsp; &nbsp;按由大到小将其排列。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　求它的第90%百分位，也就是第9个数刚好是9 ，那么他的90%Line 就是9 。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　另一组数:</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　2、2.1、2.5、3、3.4、3.4、4、4、4、4、5、5、5、5.9、5.91、6.8、8、12、24、24.1 &nbsp; 按由大到小将其排列。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　求它的第90%百分位，第18个数是12 么，他的90%Line 就是12。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">再来解释90%Line</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　一组数由小到大进行排列，找到他的第90%个数（假如是12），那么这个数组中有90%的数将小于等于12 。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　用在<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">性能测试</strong></u></a>的响应时间也将非常有意义，也就是90%用户响应时间不会超过12 秒。</div><img src ="http://www.blogjava.net/qileilove/aggbug/410807.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-10 11:11 <a href="http://www.blogjava.net/qileilove/articles/410807.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jmeter之断言</title><link>http://www.blogjava.net/qileilove/articles/410722.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Fri, 07 Mar 2014 03:35:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410722.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410722.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410722.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410722.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410722.html</trackback:ping><description><![CDATA[<table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="BeanShell_Assertion">18.5.5 BeanShell Assertion</a></h3></td></tr><tr><td><p>The BeanShell Assertion allows the user to perform assertion checking using a BeanShell script.</p><p><strong>For full details on using BeanShell, please see the&nbsp;<a href="http://www.beanshell.org/">BeanShell website.</a></strong></p><p>Note that a different Interpreter is used for each independent occurence of the assertion in each thread in a test script, but the same Interpreter is used for subsequent invocations. This means that variables persist across calls to the assertion.</p><p>All Assertions are called from the same thread as the sampler.</p><p>If the property "beanshell.assertion.init" is defined, it is passed to the Interpreter as the name of a sourced file. This can be used to define common methods and variables. There is a sample init file in the bin directory: BeanShellAssertion.bshrc</p><p>The test element supports the ThreadListener and TestListener methods. These should be defined in the initialisation file. See the file BeanShellListeners.bshrc for example definitions.</p><p><strong>Control Panel</strong></p><div align="center"><img width="849" height="633" src="http://jmeter.apache.org/images/screenshots/beanshell_assertion.png"  alt="" /></div><p><strong>Parameters</strong><a name="BeanShell_Assertion_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree. The name is stored in the script variable Label</td><td>No</td></tr><tr><td>Reset bsh.Interpreter before each call</td><td>If this option is selected, then the interpreter will be recreated for each sample. This may be necessary for some long running scripts. For further information, see&nbsp;<a href="http://jmeter.apache.org/usermanual/best-practices#bsh_scripting">Best Practices - BeanShell scripting&nbsp;</a>.</td><td>Yes</td></tr><tr><td>Parameters</td><td>Parameters to pass to the BeanShell script. The parameters are stored in the following variables:<ul><li>Parameters - string containing the parameters as a single variable</li><li>bsh.args - String array containing parameters, split on white-space</li></ul></td><td>No</td></tr><tr><td>Script file</td><td>A file containing the BeanShell script to run. This overrides the script. The file name is stored in the script variable FileName</td><td>No</td></tr><tr><td>Script</td><td>The BeanShell script to run. The return value is ignored.</td><td>Yes (unless script file is provided)</td></tr></tbody></table><p>&nbsp;</p><p>There's a&nbsp;<a href="http://jmeter.apache.org/demos/BeanShellAssertion.bsh">sample script&nbsp;</a>you can try.</p><p>Before invoking the script, some variables are set up in the BeanShell interpreter. These are strings unless otherwise noted:</p><ul><li>log - the Logger Object. (e.g.) log.warn("Message"[,Throwable])</li><li>SampleResult - the&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html">SampleResult&nbsp;</a>Object; read-write</li><li>Response - the response Object; read-write</li><li>Failure - boolean; read-write; used to set the Assertion status</li><li>FailureMessage - String; read-write; used to set the Assertion message</li><li>ResponseData - the response body (byte [])</li><li>ResponseCode - e.g. 200</li><li>ResponseMessage - e.g. OK</li><li>ResponseHeaders - contains the HTTP headers</li><li>RequestHeaders - contains the HTTP headers sent to the server</li><li>SampleLabel</li><li>SamplerData - data that was sent to the server</li><li>ctx -&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html">JMeterContext</a></li><li>vars -&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html">JMeterVariables&nbsp;</a>- e.g. vars.get("VAR1"); vars.put("VAR2","value"); vars.putObject("OBJ1",new Object());</li><li>props - JMeterProperties (class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");</li></ul><p>&nbsp;</p><p>The following methods of the Response object may be useful:</p><ul><li>setStopThread(boolean)</li><li>setStopTest(boolean)</li><li>String getSampleLabel()</li><li>setSampleLabel(String)</li></ul></td></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="BSF_Assertion">18.5.10 BSF Assertion</a></h3></td></tr><tr><td><p>The BSF Assertion allows BSF script code to be used to check the status of the previous sample.</p><p><strong>Control Panel</strong></p><div align="center"><img width="847" height="634" src="http://jmeter.apache.org/images/screenshots/bsf_assertion.png"  alt="" /></div><p><strong>Parameters</strong><a name="BSF_Assertion_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Language</td><td>The BSF language to be used</td><td>Yes</td></tr><tr><td>Parameters</td><td>Parameters to pass to the script. The parameters are stored in the following variables:<ul><li>Parameters - string containing the parameters as a single variable</li><li>args - String array containing parameters, split on white-space</li></ul></td><td>No</td></tr><tr><td>Script file</td><td>A file containing the script to run, if a relative file path is used, then it will be relative to directory referenced by "user.dir" System property</td><td>No</td></tr><tr><td>Script</td><td>The script to run.</td><td>Yes (unless script file is provided)</td></tr></tbody></table><p>&nbsp;</p><p>The script (or file) is processed using the BSFEngine.exec() method, which does not return a value.</p><p>The following variables are set up for use by the script:</p><ul><li>log - (Logger) - can be used to write to the log file</li><li>Label - the String Label</li><li>Filename - the script file name (if any)</li><li>Parameters - the parameters (as a String)</li><li>args[] - the parameters as a String array (split on whitespace)</li><li>ctx - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html">JMeterContext&nbsp;</a>) - gives access to the context</li><li>vars - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html">JMeterVariables&nbsp;</a>) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object()); vars.getObject("OBJ2");</li><li>props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");</li><li>SampleResult, prev - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html">SampleResult&nbsp;</a>) - gives access to the previous SampleResult (if any)</li><li>sampler - (Sampler)- gives access to the current sampler</li><li>OUT - System.out - e.g. OUT.println("message")</li><li>AssertionResult - the assertion result</li></ul><p>The script can check various aspects of the&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html">SampleResult&nbsp;</a>. If an error is detected, the script should use AssertionResult.setFailureMessage("message") and AssertionResult.setFailure(true).</p><p>For futher details of all the methods available on each of the above variables, please check the Javadoc</p></td></tr><tr></tr></tbody></table><br /><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Compare_Assertion">8.5.12 Compare Assertion</a></h3></td></tr><tr><td><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>Compare Assertion MUST NOT BE USED during load test as it consumes a lot of resources (memory and CPU). Use it only for either functional testing or during Test Plan debugging and Validation.</td></tr></tbody></table><p>&nbsp;</p>The Compare Assertion can be used to compare sample results within its scope. Either the contents or the elapsed time can be compared, and the contents can be filtered before comparison. The assertion comparisons can be seen in the&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#Comparison_Assertion_Visualizer">Comparison Assertion Visualizer</a>&nbsp;.<p><strong>Control Panel</strong></p><div align="center"><img width="292" height="296" src="http://jmeter.apache.org/images/screenshots/assertion/compare.png"  alt="" /></div><p><strong>Parameters</strong><a name="Compare_Assertion_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Compare Content</td><td>Whether or not to compare the content (response data)</td><td>Yes</td></tr><tr><td>Compare Time</td><td>If the value is &gt;=0, then check if the response time difference is no greater than the value. I.e. if the value is 0, then the response times must be exactly equal.</td><td>Yes</td></tr><tr><td>Comparison Filters</td><td>Filters can be used to remove strings from the content comparison. For example, if the page has a time-stamp, it might be matched with: "Time: \d\d:\d\d:\d\d" and replaced with a dummy fixed time "Time: HH:MM:SS".</td><td>No</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr><td><br /></td></tr></tbody></table><br /><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="HTML_Assertion">8.5.7 HTML Assertion</a></h3></td></tr><tr><td><p>The HTML Assertion allows the user to check the HTML syntax of the response data using JTidy.</p><p><strong>Control Panel</strong></p><div align="center"><img width="464" height="384" src="http://jmeter.apache.org/images/screenshots/assertion/HTMLAssertion.png"  alt="" /></div><p><strong>Parameters</strong><a name="HTML_Assertion_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>doctype</td><td>omit/auto/strict/loose</td><td>Yes</td></tr><tr><td>Format</td><td>HTML, XHTML or XML</td><td>Yes</td></tr><tr><td>Errors only</td><td>Only take note of errors?</td><td>Yes</td></tr><tr><td>Error threshold</td><td>Number of errors allowed before classing the response as failed</td><td>Yes</td></tr><tr><td>Warning threshold</td><td>Number of warnings allowed before classing the response as failed</td><td>Yes</td></tr><tr><td>Filename</td><td>Name of file to which report is written</td><td>No</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr></tr></tbody></table><br /><h3><a name="MD5Hex_Assertion">18.5.6 MD5Hex Assertion</a></h3><p>The MD5Hex Assertion allows the user to check the MD5 hash of the response data.</p><p><strong>Control Panel</strong></p><div align="center"><img width="411" height="149" src="http://jmeter.apache.org/images/screenshots/assertion/MD5HexAssertion.png"  alt="" /></div><p><strong>Parameters</strong><a name="MD5Hex_Assertion_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>MD5 sum</td><td>32 hex digits representing the MD5 hash (case not significant)</td><td>Yes</td></tr></tbody></table><p>&nbsp;</p><br /><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Size_Assertion">18.5.3 Size Assertion</a></h3></td></tr><tr><td><p>The Size Assertion tests that each response contains the right number of bytes in it. You can specify that the size be equal to, greater than, less than, or not equal to a given number of bytes.</p><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>Since JMeter 2.3RC3, an empty response is treated as being 0 bytes rather than reported as an error.</td></tr></tbody></table><p>&nbsp;</p><p><strong>Control Panel</strong></p><div align="center"><img width="732" height="358" src="http://jmeter.apache.org/images/screenshots/size_assertion.png"  alt="" /></div><p><strong>Parameters</strong><a name="Size_Assertion_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Apply to:</td><td>This is for use with samplers that can generate sub-samples, e.g. HTTP Sampler with embedded resources, Mail Reader or samples generated by the Transaction Controller.<ul><li>Main sample only - assertion only applies to the main sample</li><li>Sub-samples only - assertion only applies to the sub-samples</li><li>Main sample and sub-samples - assertion applies to both.</li><li>JMeter Variable - assertion is to be applied to the contents of the named variable</li></ul></td><td>Yes</td></tr><tr><td>Size in bytes</td><td>The number of bytes to use in testing the size of the response (or value of the JMeter variable).</td><td>Yes</td></tr><tr><td>Type of Comparison</td><td>Whether to test that the response is equal to, greater than, less than, or not equal to, the number of bytes specified.</td><td>Yes</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr><td><br /></td></tr></tbody></table><br /><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="SMIME_Assertion">18.5.13 SMIME Assertion</a></h3></td></tr><tr><td>The SMIME Assertion can be used to evaluate the sample results from the Mail Reader Sampler. This assertion verifies if the body of a mime message is signed or not. The signature can also be verified against a specific signer certificate. As this is a functionality that is not necessarily needed by most users, additional jars need to be downloaded and added to JMETER_HOME/lib :&nbsp;<br /><ul><li>bcmail-xxx.jar (BouncyCastle SMIME/CMS)</li><li>bcprov-xxx.jar (BouncyCastle Provider)</li></ul>These need to be&nbsp;<a href="http://www.bouncycastle.org/latest_releases.html">downloaded from BouncyCastle.</a><p>If using the&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#Mail_Reader_Sampler">Mail Reader Sampler</a>&nbsp;, please ensure that you select "Store the message using MIME (raw)" otherwise the Assertion won't be able to process the message correctly.</p><p><strong>Control Panel</strong></p><div align="center"><img width="471" height="428" src="http://jmeter.apache.org/images/screenshots/assertion/smime.png"  alt="" /></div><p><strong>Parameters</strong><a name="SMIME_Assertion_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Verify Signature</td><td>If selected, the asertion will verify if it is a valid signature according to the parameters defined in the Signer Certificate box.</td><td>Yes</td></tr><tr><td>Message not signed</td><td>Whether or not to expect a signature in the message</td><td>Yes</td></tr><tr><td>Signer Cerificate</td><td>"No Check" means that it wil not perform signature verification. "Check values" is used to verify the signature against the inputs provided. And "Certificate file" will perform the verification against a specific certificate file.</td><td>Yes</td></tr><tr><td>Message Position</td><td>The Mail sampler can retrieve multiple messages in a single sample. Use this field to specify which message will be checked. Messages are numbered from 0, so 0 means the first message. Negative numbers count from the LAST message; -1 means LAST, -2 means penultimate etc.</td><td>Yes</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr></tr></tbody></table><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="XML_Schema_Assertion">18.5.9 XML Schema Assertion</a></h3></td></tr><tr><td><p>The XML Schema Assertion allows the user to validate a response against an XML Schema.</p><p><strong>Control Panel</strong></p><div align="center"><img width="472" height="132" src="http://jmeter.apache.org/images/screenshots/assertion/XMLSchemaAssertion.png"  alt="" /></div><p><strong>Parameters</strong><a name="XML_Schema_Assertion_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>File Name</td><td>Specify XML Schema File Name</td><td>Yes</td></tr></tbody></table></td></tr></tbody></table><br /><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="XML_Assertion">18.5.4 XML Assertion</a></h3></td></tr><tr><td><p>The XML Assertion tests that the response data consists of a formally correct XML document. It does not validate the XML based on a DTD or schema or do any further validation.</p><p><strong>Control Panel</strong></p><div align="center"><img width="470" height="85" src="http://jmeter.apache.org/images/screenshots/xml_assertion.png"  alt="" /></div><p><strong>Parameters</strong>&nbsp;<a name="XML_Assertion_parms" style="width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat;"></a><a href="http://jmeter.apache.org/usermanual/component_reference.html#XML_Assertion_parms" title="Link to here" style="display: inline; color: #00ff00;">&#182;</a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr></tbody></table></td></tr></tbody></table><br /><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="XPath_Assertion">18.5.8 XPath Assertion</a></h3></td></tr><tr><td><p>The XPath Assertion tests a document for well formedness, has the option of validating against a DTD, or putting the document through JTidy and testing for an XPath. If that XPath exists, the Assertion is true. Using "/" will match any well-formed document, and is the default XPath Expression. The assertion also supports boolean expressions, such as "count(//*error)=2". See&nbsp;<a href="http://www.w3.org/TR/xpath">http://www.w3.org/TR/xpath&nbsp;</a>for more information on XPath.</p>Some sample expressions:<ul><li>//title[text()='Text to match'] - matches &lt;text&gt;Text to match&lt;/text&gt; anywhere in the response</li><li>/title[text()='Text to match'] - matches &lt;text&gt;Text to match&lt;/text&gt; at root level in the response</li></ul><p><strong>Control Panel</strong></p><div align="center"><img width="800" height="317" src="http://jmeter.apache.org/images/screenshots/xpath_assertion.png"  alt="" /></div><p><strong>Parameters</strong><a name="XPath_Assertion_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Use Tidy (tolerant parser)</td><td>Use Tidy, i.e. be tolerant of XML/HTML errors</td><td>Yes</td></tr><tr><td>Quiet</td><td>Sets the Tidy Quiet flag</td><td>If Tidy is selected</td></tr><tr><td>Report Errors</td><td>If a Tidy error occurs, then set the Assertion accordingly</td><td>If Tidy is selected</td></tr><tr><td>Show warnings</td><td>Sets the Tidy showWarnings option</td><td>If Tidy is selected</td></tr><tr><td>Use Namespaces</td><td>Should namespaces be honoured?</td><td>If Tidy is not selected</td></tr><tr><td>Validate XML</td><td>Check the document against its schema.</td><td>If Tidy is not selected</td></tr><tr><td>Ignore Whitespace</td><td>Ignore Element Whitespace.</td><td>If Tidy is not selected</td></tr><tr><td>Fetch External DTDs</td><td>If selected, external DTDs are fetched.</td><td>If Tidy is not selected</td></tr><tr><td>XPath Assertion</td><td>XPath to match in the document.</td><td>Yes</td></tr><tr><td>True if nothing matches</td><td>True if a XPath expression is not matched</td><td>No</td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>The non-tolerant parser can be quite slow, as it may need to download the DTD etc.</td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>As a work-round for namespace limitations of the Xalan XPath parser implementation on which JMeter is based, you can provide a Properties file which contains mappings for the namespace prefixes:<ul><li>prefix1=Full Namespace 1</li><li>prefix2=Full Namespace 2</li><li>...</li></ul>You reference this file in jmeter.properties file using the property:<ul><li>xpath.namespace.config</li></ul></td></tr></tbody></table><p>&nbsp;</p></td></tr><tr></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Response_Assertion">18.5.1 Response Assertion</a></h3></td></tr><tr><td><p>The response assertion control panel lets you add pattern strings to be compared against various fields of the response. The pattern strings are:</p><ul><li>Contains, Matches: Perl5-style regular expressions</li><li>Equals, Substring: plain text, case-sensitive</li></ul><p>&nbsp;</p><p>A summary of the pattern matching characters can be found at&nbsp;<a href="http://jakarta.apache.org/oro/api/org/apache/oro/text/regex/package-summary.html">ORO Perl5 regular expressions.</a></p><p>You can also choose whether the strings will be expected to&nbsp;<strong>match&nbsp;</strong>the entire response, or if the response is only expected to&nbsp;<strong>contain&nbsp;</strong>the pattern. You can attach multiple assertions to any controller for additional flexibility.</p><p>Note that the pattern string should not include the enclosing delimiters, i.e. use&nbsp;<strong>Price: \d+&nbsp;</strong>not&nbsp;<strong>/Price: \d+/&nbsp;</strong>.</p><p>By default, the pattern is in multi-line mode, which means that the "." meta-character does not match newline. In multi-line mode, "^" and "$" match the start or end of any line anywhere within the string - not just the start and end of the entire string. Note that \s does match new-line. Case is also significant. To override these settings, one can use the&nbsp;<em>extended regular expression&nbsp;</em>syntax. For example:</p><pre>    (?i) - ignore case     (?s) - treat target as single line, i.e. "." matches new-line     (?is) - both the above     These can be used anywhere within the expression and remain in effect until overriden.  e.g.     (?i)apple(?-i) Pie - matches "ApPLe Pie", but not "ApPLe pIe"     (?s)Apple.+?Pie - matches Apple followed by Pie, which may be on a subsequent line.     Apple(?s).+?Pie - same as above, but it's probably clearer to use the (?s) at the start.    </pre><p><strong>Control Panel</strong></p><div align="center"><img width="921" height="423" src="http://jmeter.apache.org/images/screenshots/assertion/assertion.png"  alt="" /></div><p><strong>Parameters</strong><a name="Response_Assertion_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Apply to:</td><td>This is for use with samplers that can generate sub-samples, e.g. HTTP Sampler with embedded resources, Mail Reader or samples generated by the Transaction Controller.<ul><li>Main sample only - assertion only applies to the main sample</li><li>Sub-samples only - assertion only applies to the sub-samples</li><li>Main sample and sub-samples - assertion applies to both.</li><li>JMeter Variable - assertion is to be applied to the contents of the named variable</li></ul></td><td>Yes</td></tr><tr><td>Response Field to Test</td><td>Instructs JMeter which field of the Response to test.<ul><li>Text Response - the response text from the server, i.e. the body, excluding any HTTP headers.</li><li>Document (text) - the extract text from various type of documents via Apache Tika (see&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#View_Results_Tree">View Results Tree</a>&nbsp;Document view section).</li><li>URL sampled</li><li>Response Code - e.g. 200</li><li>Response Message - e.g. OK</li><li>Response Headers, including Set-Cookie headers (if any)</li></ul></td><td>Yes</td></tr><tr><td>Ignore status</td><td>Instructs JMeter to set the status to success initially.<p>The overall success of the sample is determined by combining the result of the assertion with the existing Response status. When the Ignore Status checkbox is selected, the Response status is forced to successful before evaluating the Assertion.</p>HTTP Responses with statuses in the 4xx and 5xx ranges are normally regarded as unsuccessful. The "Ignore status" checkbox can be used to set the status successful before performing further checks. Note that this will have the effect of clearing any previous assertion failures, so make sure that this is only set on the first assertion.</td><td>Yes</td></tr><tr><td>Pattern Matching Rules</td><td>Indicates how the text being tested is checked against the pattern.<ul><li>Contains - true if the text contains the regular expression pattern</li><li>Matches - true if the whole text matches the regular expression pattern</li><li>Equals - true if the whole text equals the pattern string (case-sensitive)</li><li>Substring - true if the text contains the pattern string (case-sensitive)</li></ul>Equals and Substring patterns are plain strings, not regular expressions. NOT may also be selected to invert the result of the check.</td><td>Yes</td></tr><tr><td>Patterns to Test</td><td>A list of patterns to be tested. Each pattern is tested separately. If a pattern fails, then further patterns are not checked. There is no difference between setting up one Assertion with multiple patterns and setting up multiple Assertions with one pattern each (assuming the other options are the same).&nbsp;<strong>However, when the Ignore Status checkbox is selected, this has the effect of cancelling any previous assertion failures - so make sure that the Ignore Status checkbox is only used on the first Assertion.</strong></td><td>Yes</td></tr></tbody></table><p>&nbsp;</p><p>The pattern is a Perl5-style regular expression, but without the enclosing brackets.</p><a name="assertion_examples"></a><p><strong>Assertion Examples</strong></p><center><p>&nbsp;</p><table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><img width="242" height="123" src="http://jmeter.apache.org/images/screenshots/assertion/example1a.png"  alt="" /><br />Figure 14 - Test Plan</td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p><table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><img width="920" height="451" src="http://jmeter.apache.org/images/screenshots/assertion/example1b.png"  alt="" /><br />Figure 15 - Assertion Control Panel with Pattern</td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p><table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><img width="801" height="230" src="http://jmeter.apache.org/images/screenshots/assertion/example1c-pass.png"  alt="" /><br />Figure 16 - Assertion Listener Results (Pass)</td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p><table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><img width="800" height="233" src="http://jmeter.apache.org/images/screenshots/assertion/example1c-fail.png"  alt="" /><br />Figure 17 - Assertion Listener Results (Fail)</td></tr></tbody></table><p>&nbsp;</p></center></td></tr><tr></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Duration_Assertion">18.5.2 Duration Assertion</a></h3></td></tr><tr><td><p>The Duration Assertion tests that each response was received within a given amount of time. Any response that takes longer than the given number of milliseconds (specified by the user) is marked as a failed response.</p><p><strong>Control Panel</strong></p><div align="center"><img width="606" height="187" src="http://jmeter.apache.org/images/screenshots/duration_assertion.png"  alt="" /></div><p><strong>Parameters</strong><a name="Duration_Assertion_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Duration in Milliseconds</td><td>The maximum number of milliseconds each response is allowed before being marked as failed.</td><td>Yes</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr><td><br /></td></tr></tbody></table><img src ="http://www.blogjava.net/qileilove/aggbug/410722.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-07 11:35 <a href="http://www.blogjava.net/qileilove/articles/410722.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jmeter 之后置处理器</title><link>http://www.blogjava.net/qileilove/articles/410674.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Thu, 06 Mar 2014 03:10:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410674.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410674.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410674.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410674.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410674.html</trackback:ping><description><![CDATA[<table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="BeanShell_PostProcessor">18.8.5 BeanShell PostProcessor</a></h3></td></tr><tr><td><p>The BeanShell PreProcessor allows arbitrary code to be applied after taking a sample.</p><p>For JMeter versions after 2.2 the BeanShell Post-Processor no longer ignores samples with zero-length result data</p><p><strong>For full details on using BeanShell, please see the&nbsp;<a href="http://www.beanshell.org/">BeanShell website.</a></strong></p><p>The test element supports the ThreadListener and TestListener methods. These should be defined in the initialisation file. See the file BeanShellListeners.bshrc for example definitions.</p><p><strong>Control Panel</strong></p><div align="center"><img width="847" height="633" src="http://jmeter.apache.org/images/screenshots/beanshell_postprocessor.png"  alt="" /></div><p><strong>Parameters</strong><a name="BeanShell_PostProcessor_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree. The name is stored in the script variable Label</td><td>No</td></tr><tr><td>Reset bsh.Interpreter before each call</td><td>If this option is selected, then the interpreter will be recreated for each sample. This may be necessary for some long running scripts. For further information, see&nbsp;<a href="http://jmeter.apache.org/usermanual/best-practices#bsh_scripting">Best Practices - BeanShell scripting&nbsp;</a>.</td><td>Yes</td></tr><tr><td>Parameters</td><td>Parameters to pass to the BeanShell script. The parameters are stored in the following variables:<ul><li>Parameters - string containing the parameters as a single variable</li><li>bsh.args - String array containing parameters, split on white-space</li></ul></td><td>No</td></tr><tr><td>Script file</td><td>A file containing the BeanShell script to run. The file name is stored in the script variable FileName</td><td>No</td></tr><tr><td>Script</td><td>The BeanShell script. The return value is ignored.</td><td>Yes (unless script file is provided)</td></tr></tbody></table><p>&nbsp;</p><p>The following BeanShell variables are set up for use by the script:</p><ul><li>log - (Logger) - can be used to write to the log file</li><li>ctx - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html">JMeterContext&nbsp;</a>) - gives access to the context</li><li>vars - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html">JMeterVariables&nbsp;</a>) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object());</li><li>props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");</li><li>prev - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html">SampleResult&nbsp;</a>) - gives access to the previous SampleResult</li><li>data - (byte [])- gives access to the current sample data</li></ul><p>For details of all the methods available on each of the above variables, please check the Javadoc</p><p>If the property&nbsp;<strong>beanshell.postprocessor.init&nbsp;</strong>is defined, this is used to load an initialisation file, which can be used to define methods etc for use in the BeanShell script.</p></td></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="BSF_PostProcessor">18.8.6 BSF PostProcessor</a></h3></td></tr><tr><td><p>The BSF PostProcessor allows BSF script code to be applied after taking a sample.</p><p><strong>Control Panel</strong></p><div align="center"><img width="844" height="633" src="http://jmeter.apache.org/images/screenshots/bsf_postprocessor.png"  alt="" /></div><p><strong>Parameters</strong><a name="BSF_PostProcessor_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Language</td><td>The BSF language to be used</td><td>Yes</td></tr><tr><td>Parameters</td><td>Parameters to pass to the script. The parameters are stored in the following variables:<ul><li>Parameters - string containing the parameters as a single variable</li><li>args - String array containing parameters, split on white-space</li></ul></td><td>No</td></tr><tr><td>Script file</td><td>A file containing the script to run, if a relative file path is used, then it will be relative to directory referenced by "user.dir" System property</td><td>No</td></tr><tr><td>Script</td><td>The script to run.</td><td>Yes (unless script file is provided)</td></tr></tbody></table><p>&nbsp;</p><p>The script (or file) is processed using the BSFEngine.exec() method, which does not return a value.</p><p>Before invoking the script, some variables are set up. Note that these are BSF variables - i.e. they can be used directly in the script.</p><ul><li>log - (Logger) - can be used to write to the log file</li><li>Label - the String Label</li><li>Filename - the script file name (if any)</li><li>Parameters - the parameters (as a String)</li><li>args[] - the parameters as a String array (split on whitespace)</li><li>ctx - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html">JMeterContext&nbsp;</a>) - gives access to the context</li><li>vars - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html">JMeterVariables&nbsp;</a>) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object()); vars.getObject("OBJ2");</li><li>props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");</li><li>prev - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html">SampleResult&nbsp;</a>) - gives access to the previous SampleResult (if any)</li><li>sampler - (Sampler)- gives access to the current sampler</li><li>OUT - System.out - e.g. OUT.println("message")</li></ul><p>For details of all the methods available on each of the above variables, please check the Javadoc</p></td></tr></tbody></table><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Debug_PostProcessor">18.9.8 Debug PostProcessor</a></h3></td></tr><tr><td><p>The Debug PostProcessor creates a subSample with the details of the previous Sampler properties, JMeter variables, properties and/or System Properties.</p><p>The values can be seen in the&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#View_Results_Tree">View Results Tree</a>&nbsp;Listener Response Data pane.</p><p><strong>Control Panel</strong></p><div align="center"><img width="344" height="193" src="http://jmeter.apache.org/images/screenshots/debug_postprocessor.png"  alt="" /></div><p><strong>Parameters</strong><a name="Debug_PostProcessor_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>JMeter Properties</td><td>Whether to show JMeter properties (default false).</td><td>Yes</td></tr><tr><td>JMeter Variables</td><td>Whether to show JMeter variables (default false).</td><td>Yes</td></tr><tr><td>Sampler Properties</td><td>Whether to show Sampler properties (default true).</td><td>Yes</td></tr><tr><td>System Properties</td><td>Whether to show System properties (default false).</td><td>Yes</td></tr></tbody></table></td></tr></tbody></table><br /><br /><table border="0" cellspacing="0" cellpadding="2" width="100%" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><blockquote><table border="0" cellspacing="0" cellpadding="2"><tbody><tr><td><h3><a name="JDBC_PostProcessor">18.8.8 JDBC PostProcessor</a></h3></td></tr><tr><td><p>The JDBC PostProcessor enables you to run some SQL statement just after a sample has run. This can be useful if your JDBC Sample changes some data and you want to reset state to what it was before the JDBC sample run.</p></td></tr><tr><td><br /></td></tr></tbody></table><hr /><p><strong>See Also:</strong></p><ul><li><a href="http://jmeter.apache.org/demos/JDBC-Pre-Post-Processor.jmx">Test Plan using JDBC Pre/Post Processor</a></li></ul><p>&nbsp;</p><p>In the linked test plan,"JDBC PostProcessor" JDBC PostProcessor calls a stored procedure to delete from Database the Price Cut-Off that was created by PreProcessor.</p><p>&nbsp;</p><table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><img width="818" height="399" src="http://jmeter.apache.org/images/screenshots/jdbc-post-processor.png"  alt="" /><br />JDBC PostProcessor</td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p></blockquote><p>&nbsp;</p></td></tr><tr></tr></tbody></table><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Result_Status_Action_Handler">8.8.4 Result Status Action Handler</a></h3></td></tr><tr><td>This test element allows the user to stop the thread or the whole test if the relevant sampler failed.<p><strong>Control Panel</strong></p><div align="center"><img width="613" height="133" src="http://jmeter.apache.org/images/screenshots/resultstatusactionhandler.png"  alt="" /></div><p><strong>Parameters</strong><a name="Result_Status_Action_Handler_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Action to be taken after a Sampler error</td><td>Determines what happens if a sampler error occurs, either because the sample itself failed or an assertion failed. The possible choices are:<ul><li>Continue - ignore the error and continue with the test</li><li>Start next thread loop - does not execute samplers following the sampler in error for the current iteration and restarts the loop on next iteration</li><li>Stop Thread - current thread exits</li><li>Stop Test - the entire test is stopped at the end of any current samples.</li><li>Stop Test Now - the entire test is stopped abruptly. Any current samplers are interrupted if possible.</li></ul></td><td>No</td></tr></tbody></table></td></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="XPath_Extractor">18.8.3 XPath Extractor</a></h3></td></tr><tr><td>This test element allows the user to extract value(s) from structured response - XML or (X)HTML - using XPath query language.<p><strong>Control Panel</strong></p><div align="center"><img width="729" height="317" src="http://jmeter.apache.org/images/screenshots/xpath_extractor.png"  alt="" /></div><p><strong>Parameters</strong><a name="XPath_Extractor_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Apply to:</td><td>This is for use with samplers that can generate sub-samples, e.g. HTTP Sampler with embedded resources, Mail Reader or samples generated by the Transaction Controller.<ul><li>Main sample only - only applies to the main sample</li><li>Sub-samples only - only applies to the sub-samples</li><li>Main sample and sub-samples - applies to both.</li><li>JMeter Variable - assertion is to be applied to the contents of the named variable</li></ul>XPath matching is applied to all qualifying samples in turn, and all the matching results will be returned.</td><td>Yes</td></tr><tr><td>Use Tidy (tolerant parser)</td><td>If checked use Tidy to parse HTML response into XHTML.<ul><li>"Use Tidy" should be checked on for HTML response. Such response is converted to valid XHTML (XML compatible HTML) using Tidy</li><li>"Use Tidy" should be unchecked for both XHTML or XML response (for example RSS)</li></ul></td><td>Yes</td></tr><tr><td>Quiet</td><td>Sets the Tidy Quiet flag</td><td>If Tidy is selected</td></tr><tr><td>Report Errors</td><td>If a Tidy error occurs, then set the Assertion accordingly</td><td>If Tidy is selected</td></tr><tr><td>Show warnings</td><td>Sets the Tidy showWarnings option</td><td>If Tidy is selected</td></tr><tr><td>Use Namespaces</td><td>If checked, then the XML parser will use namespace resolution. Note that currently only namespaces declared on the root element will be recognised. A later version of JMeter may support user-definition of additional workspace names. Meanwhile, a work-round is to replace:&nbsp;<br />//mynamespace:tagname&nbsp;<br />by&nbsp;<br />//*[local-name()='tagname' and namespace-uri()='uri-for-namespace']&nbsp;<br />where "uri-for-namespace" is the uri for the "mynamespace" namespace. (not applicable if Tidy is selected)</td><td>If Tidy is not selected</td></tr><tr><td>Validate XML</td><td>Check the document against its schema.</td><td>If Tidy is not selected</td></tr><tr><td>Ignore Whitespace</td><td>Ignore Element Whitespace.</td><td>If Tidy is not selected</td></tr><tr><td>Fetch External DTDs</td><td>If selected, external DTDs are fetched.</td><td>If Tidy is not selected</td></tr><tr><td>Return entire XPath fragment instead of text content?</td><td>If selected, the fragment will be returned rather than the text content.&nbsp;<br />For example //title would return "&lt;title&gt;Apache JMeter&lt;/title&gt;" rather than "Apache JMeter".&nbsp;<br />In this case, //title/text() would return "Apache JMeter".</td><td>Yes</td></tr><tr><td>Reference Name</td><td>The name of the JMeter variable in which to store the result.</td><td>Yes</td></tr><tr><td>XPath Query</td><td>Element query in XPath language. Can return more than one match.</td><td>Yes</td></tr><tr><td>Default Value</td><td>Default value returned when no match found. It is also returned if the node has no value and the fragment option is not selected.</td><td>No</td></tr></tbody></table><p>&nbsp;</p><p>To allow for use in a ForEach Controller, the following variables are set on return:</p><ul><li>refName - set to first (or only) match; if no match, then set to default</li><li>refName_matchNr - set to number of matches (may be 0)</li><li>refName_n - n=1,2,3 etc. Set to the 1st, 2nd 3rd match etc.</li></ul><p>Note: The next refName_n variable is set to null - e.g. if there are 2 matches, then refName_3 is set to null, and if there are no matches, then refName_1 is set to null.</p><p>XPath is query language targeted primarily for XSLT transformations. However it is usefull as generic query language for structured data too. See&nbsp;<a href="http://www.topxml.com/xsl/xpathref.asp">XPath Reference&nbsp;</a>or&nbsp;<a href="http://www.w3.org/TR/xpath">XPath specification&nbsp;</a>for more information. Here are few examples:</p><dl><dt>/html/head/title</dt><dd>extracts title element from HTML response</dd><dt>/book/page[2]</dt><dd>extracts 2nd page from a book</dd><dt>/book/page</dt><dd>extracts all pages from a book</dd><dt>//form[@name='countryForm']//select[@name='country']/option[text()='Czech Republic'])/@value</dt><dd>extracts value attribute of option element that match text 'Czech Republic' inside of select element with name attribute 'country' inside of form with name attribute 'countryForm'</dd></dl><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>When "Use Tidy" is checked on - resulting XML document may slightly differ from original HTML response:<ul><li>All elements and attribute names are converted to lowercase</li><li>Tidy attempts to correct improperly nested elements. For example - original (incorrect)&nbsp;<code>ul/font/li&nbsp;</code>becomes correct&nbsp;<code>ul/li/font</code></li></ul>See&nbsp;<a href="http://jtidy.sf.net/">Tidy homepage&nbsp;</a>for more information.</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Regular_Expression_Extractor">18.8.1 Regular Expression Extractor</a></h3></td></tr><tr><td><p>Allows the user to extract values from a server response using a Perl-type regular expression. As a post-processor, this element will execute after each Sample request in its scope, applying the regular expression, extracting the requested values, generate the template string, and store the result into the given variable name.</p><p><strong>Control Panel</strong></p><div align="center"><img width="790" height="276" src="http://jmeter.apache.org/images/screenshots/regex_extractor.png"  alt="" /></div><p><strong>Parameters</strong><a name="Regular_Expression_Extractor_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Apply to:</td><td>This is for use with samplers that can generate sub-samples, e.g. HTTP Sampler with embedded resources, Mail Reader or samples generated by the Transaction Controller.<ul><li>Main sample only - only applies to the main sample</li><li>Sub-samples only - only applies to the sub-samples</li><li>Main sample and sub-samples - applies to both.</li><li>JMeter Variable - assertion is to be applied to the contents of the named variable</li></ul>Matching is applied to all qualifying samples in turn. For example if there is a main sample and 3 sub-samples, each of which contains a single match for the regex, (i.e. 4 matches in total). For match number = 3, Sub-samples only, the extractor will match the 3rd sub-sample. For match number = 3, Main sample and sub-samples, the extractor will match the 2nd sub-sample (1st match is main sample). For match number = 0 or negative, all qualifying samples will be processed. For match number &gt; 0, matching will stop as soon as enough matches have been found.</td><td>Yes</td></tr><tr><td>Response Field to check</td><td>The following response fields can be checked:<ul><li>Body - the body of the response, e.g. the content of a web-page (excluding headers)</li><li>Body (unescaped) - the body of the response, with all Html escape codes replaced. Note that Html escapes are processed without regard to context, so some incorrect substitutions may be made.<p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>Note that this option highly impacts performances, so use it only when absolutely necessary and be aware of its impacts</td></tr></tbody></table><p>&nbsp;</p></li><li>Body as a Document - the extract text from various type of documents via Apache Tika (see&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#View_Results_Tree">View Results Tree</a>&nbsp;Document view section).<p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>Note that Body as a Document option can impact performances, so ensure it is Ok for your test</td></tr></tbody></table><p>&nbsp;</p></li><li>Headers - may not be present for non-HTTP samples</li><li>URL</li><li>Response Code - e.g. 200</li><li>Response Message - e.g. OK</li></ul>Headers can be useful for HTTP samples; it may not be present for other sample types.</td><td>Yes</td></tr><tr><td>Reference Name</td><td>The name of the JMeter variable in which to store the result. Also note that each group is stored as [refname]_g#, where [refname] is the string you entered as the reference name, and # is the group number, where group 0 is the entire match, group 1 is the match from the first set of parentheses, etc.</td><td>Yes</td></tr><tr><td>Regular Expression</td><td>The regular expression used to parse the response data. This must contain at least one set of parentheses "()" to capture a portion of the string, unless using the group $0$. Do not enclose the expression in / / - unless of course you want to match these characters as well.</td><td>Yes</td></tr><tr><td>Template</td><td>The template used to create a string from the matches found. This is an arbitrary string with special elements to refer to groups within the regular expression. The syntax to refer to a group is: '$1$' to refer to group 1, '$2$' to refer to group 2, etc. $0$ refers to whatever the entire expression matches.</td><td>Yes</td></tr><tr><td>Match No.</td><td>Indicates which match to use. The regular expression may match multiple times.<ul><li>Use a value of zero to indicate JMeter should choose a match at random.</li><li>A positive number N means to select the nth match.</li><li>Negative numbers are used in conjunction with the ForEach controller - see below.</li></ul></td><td>Yes</td></tr><tr><td>Default Value</td><td>If the regular expression does not match, then the reference variable will be set to the default value. This is particularly useful for debugging tests. If no default is provided, then it is difficult to tell whether the regular expression did not match, or the RE element was not processed or maybe the wrong variable is being used.<p>However, if you have several test elements that set the same variable, you may wish to leave the variable unchanged if the expression does not match. In this case, remove the default value once debugging is complete.</p></td><td>No, but recommended</td></tr></tbody></table><p>&nbsp;</p><p>If the match number is set to a non-negative number, and a match occurs, the variables are set as follows:</p><ul><li>refName - the value of the template</li><li>refName_gn, where n=0,1,2 - the groups for the match</li><li>refName_g - the number of groups in the Regex (excluding 0)</li></ul>If no match occurs, then the refName variable is set to the default (unless this is absent). Also, the following variables are removed:<ul><li>refName_g0</li><li>refName_g1</li><li>refName_g</li></ul><p>&nbsp;</p><p>If the match number is set to a negative number, then all the possible matches in the sampler data are processed. The variables are set as follows:</p><ul><li>refName_matchNr - the number of matches found; could be 0</li><li>refName_n, where n = 1,2,3 etc - the strings as generated by the template</li><li>refName_n_gm, where m=0,1,2 - the groups for match n</li><li>refName - always set to the default value</li><li>refName_gn - not set</li></ul>Note that the refName variable is always set to the default value in this case, and the associated group variables are not set.<p>See also&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#Response_Assertion">Response Assertion</a>&nbsp;for some examples of how to specify modifiers, and&nbsp;<a href="http://jmeter.apache.org/usermanual/regular_expressions.html">for further information on JMeter regular expressions.</a></p><p>&nbsp;</p></td></tr><tr><td><br /></td></tr></tbody></table><img src ="http://www.blogjava.net/qileilove/aggbug/410674.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-06 11:10 <a href="http://www.blogjava.net/qileilove/articles/410674.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jmeter sample 取样器</title><link>http://www.blogjava.net/qileilove/articles/410630.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Wed, 05 Mar 2014 03:25:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410630.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410630.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410630.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410630.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410630.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Control PanelParametersAttributeDescriptionRequiredNameDescriptive name for this sampler that is shown in the tree.NoServerDomain name or IP address of the web server.YesPortPort the web server is lis...&nbsp;&nbsp;<a href='http://www.blogjava.net/qileilove/articles/410630.html'>阅读全文</a><img src ="http://www.blogjava.net/qileilove/aggbug/410630.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-05 11:25 <a href="http://www.blogjava.net/qileilove/articles/410630.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jmeter之前置处理器</title><link>http://www.blogjava.net/qileilove/articles/410580.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Tue, 04 Mar 2014 03:19:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410580.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410580.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410580.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410580.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410580.html</trackback:ping><description><![CDATA[<table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="BeanShell_PreProcessor">18.7.7 BeanShell PreProcessor</a></h3></td></tr><tr><td><p>The BeanShell PreProcessor allows arbitrary code to be applied before taking a sample.</p><p><strong>For full details on using BeanShell, please see the&nbsp;<a href="http://www.beanshell.org/">BeanShell website.</a></strong></p><p>The test element supports the ThreadListener and TestListener methods. These should be defined in the initialisation file. See the file BeanShellListeners.bshrc for example definitions.</p><p><strong>Control Panel</strong></p><div align="center"><img width="845" height="633" src="http://jmeter.apache.org/images/screenshots/beanshell_preprocessor.png" alt="" /></div><p><strong>Parameters</strong><a name="BeanShell_PreProcessor_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree. The name is stored in the script variable Label</td><td>No</td></tr><tr><td>Reset bsh.Interpreter before each call</td><td>If this option is selected, then the interpreter will be recreated for each sample. This may be necessary for some long running scripts. For further information, see&nbsp;<a href="http://jmeter.apache.org/usermanual/best-practices#bsh_scripting">Best Practices - BeanShell scripting&nbsp;</a>.</td><td>Yes</td></tr><tr><td>Parameters</td><td>Parameters to pass to the BeanShell script. The parameters are stored in the following variables:<ul><li>Parameters - string containing the parameters as a single variable</li><li>bsh.args - String array containing parameters, split on white-space</li></ul></td><td>No</td></tr><tr><td>Script file</td><td>A file containing the BeanShell script to run. The file name is stored in the script variable FileName</td><td>No</td></tr><tr><td>Script</td><td>The BeanShell script. The return value is ignored.</td><td>Yes (unless script file is provided)</td></tr></tbody></table><p>&nbsp;</p><p>Before invoking the script, some variables are set up in the BeanShell interpreter:</p><ul><li>log - (Logger) - can be used to write to the log file</li><li>ctx - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html">JMeterContext&nbsp;</a>) - gives access to the context</li><li>vars - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html">JMeterVariables&nbsp;</a>) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object());</li><li>props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");</li><li>prev - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html">SampleResult&nbsp;</a>) - gives access to the previous SampleResult (if any)</li><li>sampler - (Sampler)- gives access to the current sampler</li></ul><p>For details of all the methods available on each of the above variables, please check the Javadoc</p><p>If the property&nbsp;<strong>beanshell.preprocessor.init&nbsp;</strong>is defined, this is used to load an initialisation file, which can be used to define methods etc for use in the BeanShell script.</p></td></tr></tbody></table><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="BSF_PreProcessor">18.7.8 BSF PreProcessor</a></h3></td></tr><tr><td><p>The BSF PreProcessor allows BSF script code to be applied before taking a sample.</p><p><strong>Control Panel</strong></p><div align="center"><img width="844" height="632" src="http://jmeter.apache.org/images/screenshots/bsf_preprocessor.png" alt="" /></div><p><strong>Parameters</strong><a name="BSF_PreProcessor_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Language</td><td>The BSF language to be used</td><td>Yes</td></tr><tr><td>Parameters</td><td>Parameters to pass to the script. The parameters are stored in the following variables:<ul><li>Parameters - string containing the parameters as a single variable</li><li>args - String array containing parameters, split on white-space</li></ul></td><td>No</td></tr><tr><td>Script file</td><td>A file containing the script to run, if a relative file path is used, then it will be relative to directory referenced by "user.dir" System property</td><td>No</td></tr><tr><td>Script</td><td>The script to run.</td><td>Yes (unless script file is provided)</td></tr></tbody></table><p>&nbsp;</p><p>The script (or file) is processed using the BSFEngine.exec() method, which does not return a value.</p><p>The following BSF variables are set up for use by the script:</p><ul><li>log - (Logger) - can be used to write to the log file</li><li>Label - the String Label</li><li>Filename - the script file name (if any)</li><li>Parameters - the parameters (as a String)</li><li>args[] - the parameters as a String array (split on whitespace)</li><li>ctx - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html">JMeterContext&nbsp;</a>) - gives access to the context</li><li>vars - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html">JMeterVariables&nbsp;</a>) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object()); vars.getObject("OBJ2");</li><li>props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");</li><li>sampler - (Sampler)- gives access to the current sampler</li><li>OUT - System.out - e.g. OUT.println("message")</li></ul><p>For details of all the methods available on each of the above variables, please check the Javadoc</p></td></tr></tbody></table><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="HTML_Parameter_Mask_(DEPRECATED)">18.7.3 HTML Parameter Mask (DEPRECATED)</a></h3></td></tr><tr><td bgcolor="#bbbb00"><div align="center"><strong>*** This element is deprecated. Use&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#Counter">Counter</a>&nbsp;instead ***</strong></div></td></tr><tr><td><p>The HTML Parameter Mask is used to generate unique values for HTML arguments. By specifying the name of the parameter, a value prefix and suffix, and counter parameters, this modifier will generate values of the form "&nbsp;<code>name=prefixcountersuffix&nbsp;</code>". Any HTTP Request that it modifies, it will replace any parameter with the same name or add the appropriate parameter to the requests list of arguments.</p><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>The value of the argument in your HTTP Request must be a '*' in order for the HTML Parameter Mask Modifier to replace it.</td></tr></tbody></table><p>&nbsp;</p><p>As an example, the username for a login script could be modified to send a series of values such as:&nbsp;<br />user_1&nbsp;<br />user_2&nbsp;<br />user_3&nbsp;<br />user_4, etc.</p><p><strong>Control Panel</strong></p><div align="center"><img width="624" height="209" src="http://jmeter.apache.org/images/screenshots/parameter_mask.png" alt="" /></div><p><strong>Parameters</strong><a name="HTML_Parameter_Mask_(DEPRECATED)_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name given to this element in the test tree.</td><td>No</td></tr><tr><td>Name (second appearing)</td><td>The name of the parameter to modify or add to the HTTP Request.</td><td>Yes</td></tr><tr><td>ID Prefix</td><td>A string value to prefix to every generated value.</td><td>No</td></tr><tr><td>Lower Bound</td><td>A number value to start the counter at.</td><td>Yes</td></tr><tr><td>Upper Bound</td><td>A number value to end the counter, at which point it restarts with the Lower Bound value.</td><td>Yes</td></tr><tr><td>Increment</td><td>Value to increment the counter by each time through.</td><td>Yes</td></tr><tr><td>ID Suffix</td><td>A string value to add as suffix to every generated vaue.</td><td>No</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr></tr></tbody></table><br /><br /><table border="0" cellspacing="0" cellpadding="2"><tbody><tr style="font-family: Simsun; background-color: #ffffff;"><td><h3><a name="HTTP_URL_Re-writing_Modifier">18.7.2 HTTP URL Re-writing Modifier</a></h3></td></tr><tr style="font-family: Simsun; background-color: #ffffff;"><td><p>This modifier works similarly to the HTML Link Parser, except it has a specific purpose for which it is easier to use than the HTML Link Parser, and more efficient. For web applications that use URL Re-writing to store session ids instead of cookies, this element can be attached at the ThreadGroup level, much like the&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Cookie_Manager">HTTP Cookie Manager</a>&nbsp;. Simply give it the name of the session id parameter, and it will find it on the page and add the argument to every request of that ThreadGroup.</p><p>Alternatively, this modifier can be attached to select requests and it will modify only them. Clever users will even determine that this modifier can be used to grab values that elude the&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#HTML_Link_Parser">HTML Link Parser</a>&nbsp;.</p><p><strong>Control Panel</strong></p><div align="center"><img width="609" height="215" src="http://jmeter.apache.org/images/screenshots/url_rewriter.png" alt="" /></div><p><strong>Parameters</strong><a name="HTTP_URL_Re-writing_Modifier_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name given to this element in the test tree.</td><td>No</td></tr><tr><td>Session Argument Name</td><td>The name of the parameter to grab from previous response. This modifier will find the parameter anywhere it exists on the page, and grab the value assigned to it, whether it's in an HREF or a form.</td><td>Yes</td></tr><tr><td>Path Extension</td><td>Some web apps rewrite URLs by appending a semi-colon plus the session id parameter. Check this box if that is so.</td><td>No</td></tr><tr><td>Do not use equals in path extension</td><td>Some web apps rewrite URLs without using an "=" sign between the parameter name and value (such as Intershop Enfinity).</td><td>No</td></tr><tr><td>Do not use questionmark in path extension</td><td>Prevents the query string to end up in the path extension (such as Intershop Enfinity).</td><td>No</td></tr><tr><td>Cache Session Id?</td><td>Should the value of the session Id be saved for later use when the session Id is not present?</td><td>Yes</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr style="font-family: Simsun; background-color: #ffffff;"></tr></tbody></table><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="HTML_Link_Parser">18.7.1 HTML Link Parser</a></h3></td></tr><tr><td><p>This modifier parses HTML response from the server and extracts links and forms. A URL test sample that passes through this modifier will be examined to see if it "matches" any of the links or forms extracted from the immediately previous response. It would then replace the values in the URL test sample with appropriate values from the matching link or form. Perl-type regular expressions are used to find matches.</p><p><strong>Control Panel</strong></p><div align="center"><img width="239" height="113" src="http://jmeter.apache.org/images/screenshots/html_link_parser.png" alt="" /></div><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>Matches are performed using protocol, host, path and parameter names. The target sampler cannot contain parameters that are not in the response links.</td></tr></tbody></table><p>&nbsp;</p><a name="spider_example" style="width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat;"></a><p><strong>Spidering Example</strong></p><p>Consider a simple example: let's say you wanted JMeter to "spider" through your site, hitting link after link parsed from the HTML returned from your server (this is not actually the most useful thing to do, but it serves as a good example). You would create a&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#Simple_Controller">Simple Controller</a>&nbsp;, and add the "HTML Link Parser" to it. Then, create an HTTP Request, and set the domain to ".*", and the path likewise. This will cause your test sample to match with any link found on the returned pages. If you wanted to restrict the spidering to a particular domain, then change the domain value to the one you want. Then, only links to that domain will be followed.</p><a name="poll_example" style="width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat;"></a><p><strong>Poll Example</strong></p><p>A more useful example: given a web polling application, you might have a page with several poll options as radio buttons for the user to select. Let's say the values of the poll options are very dynamic - maybe user generated. If you wanted JMeter to test the poll, you could either create test samples with hardcoded values chosen, or you could let the HTML Link Parser parse the form, and insert a random poll option into your URL test sample. To do this, follow the above example, except, when configuring your Web Test controller's URL options, be sure to choose "POST" as the method. Put in hard-coded values for the domain, path, and any additional form parameters. Then, for the actual radio button parameter, put in the name (let's say it's called "poll_choice"), and then ".*" for the value of that parameter. When the modifier examines this URL test sample, it will find that it "matches" the poll form (and it shouldn't match any other form, given that you've specified all the other aspects of the URL test sample), and it will replace your form parameters with the matching parameters from the form. Since the regular expression ".*" will match with anything, the modifier will probably have a list of radio buttons to choose from. It will choose at random, and replace the value in your URL test sample. Each time through the test, a new random value will be chosen.</p><p>&nbsp;</p><table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><img width="755" height="325" src="http://jmeter.apache.org/images/screenshots/modification.png" alt="" /><br />Figure 18 - Online Poll Example</td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>One important thing to remember is that you must create a test sample immediately prior that will return an HTML page with the links and forms that are relevant to your dynamic test sample.</td></tr></tbody></table></td></tr></tbody></table><br /><br /><table border="0" cellspacing="0" cellpadding="2"><tbody><tr style="font-family: Simsun; background-color: #ffffff;"><td><h3><a name="JDBC_PreProcessor">18.7.9 JDBC PreProcessor</a></h3></td></tr><tr style="font-family: Simsun; background-color: #ffffff;"><td><p>The JDBC PreProcessor enables you to run some SQL statement just before a sample runs. This can be useful if your JDBC Sample requires some data to be in DataBase and you cannot compute this in a setup Thread group. For details, see&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#JDBC_Request">JDBC Request</a>&nbsp;.</p><p>See the following Test plan:</p><p><strong>See Also:</strong></p><ul><li><a href="http://jmeter.apache.org/demos/JDBC-Pre-Post-Processor.jmx">Test Plan using JDBC Pre/Post Processor</a></li></ul><p>&nbsp;</p><p>In the linked test plan,"Create Price Cut-Off" JDBC PreProcessor calls a stored procedure to create a Price Cut-Off in Database, this one will be used by "Calculate Price cut off".</p><p>&nbsp;</p><table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><img width="818" height="394" src="http://jmeter.apache.org/images/screenshots/jdbc-pre-processor.png" alt="" /><br />Create Price Cut-Off Preprocessor</td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p></td></tr><tr style="font-family: Simsun; background-color: #ffffff;"></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="User_Defined_Variables">18.4.14 User Defined Variables</a></h3></td></tr><tr><td><p>The User Defined Variables element lets you define an&nbsp;<strong>initial set of variables&nbsp;</strong>, just as in the&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#Test_Plan">Test Plan</a>&nbsp;.&nbsp;<strong>Note that all the UDV elements in a test plan - no matter where they are - are processed at the start.&nbsp;</strong>So you cannot reference variables which are defined as part of a test run, e.g. in a Post-Processor.</p><p><strong>UDVs should not be used with functions that generate different results each time they are called. Only the result of the first function call will be saved in the variable.&nbsp;</strong>However, UDVs can be used with functions such as __P(), for example:</p><pre>HOST      ${__P(host,localhost)}   </pre>which would define the variable "HOST" to have the value of the JMeter property "host", defaulting to "localhost" if not defined.<p>&nbsp;</p><p>For defining variables during a test run, see&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#User_Parameters">User Parameters</a>&nbsp;. UDVs are processed in the order they appear in the Plan, from top to bottom.</p><p>For simplicity, it is suggested that UDVs are placed only at the start of a Thread Group (or perhaps under the Test Plan itself).</p><p>Once the Test Plan and all UDVs have been processed, the resulting set of variables is copied to each thread to provide the initial set of variables.</p><p>If a runtime element such as a User Parameters Pre-Processor or Regular Expression Extractor defines a variable with the same name as one of the UDV variables, then this will replace the initial value, and all other test elements in the thread will see the updated value.</p><p><strong>Control Panel</strong></p><div align="center"><img width="741" height="266" src="http://jmeter.apache.org/images/screenshots/user_defined_variables.png" alt="" /></div><p>&nbsp;</p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2"><tbody><tr><td>If you have more than one Thread Group, make sure you use different names for different values, as UDVs are shared between Thread Groups. Also, the variables are not available for use until after the element has been processed, so you cannot reference variables that are defined in the same element. You can reference variables defined in earlier UDVs or on the Test Plan.</td></tr></tbody></table><p>&nbsp;</p><p><strong>Parameters</strong><a name="User_Defined_Variables_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>User Defined Variables</td><td>Variable name/value pairs. The string under the "Name" column is what you'll need to place inside the brackets in ${...} constructs to use the variables later on. The whole ${...} will then be replaced by the string in the "Value" column.</td><td>No</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr><td><br /></td></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="User_Parameters">18.7.5 User Parameters</a></h3></td></tr><tr><td><p>Allows the user to specify values for User Variables specific to individual threads.</p><p>User Variables can also be specified in the Test Plan but not specific to individual threads. This panel allows you to specify a series of values for any User Variable. For each thread, the variable will be assigned one of the values from the series in sequence. If there are more threads than values, the values get re-used. For example, this can be used to assign a distinct user id to be used by each thread. User variables can be referenced in any field of any jMeter Component.</p><p>The variable is specified by clicking the Add Variable button in the bottom of the panel and filling in the Variable name in the 'Name:' column. To add a new value to the series, click the 'Add User' button and fill in the desired value in the newly added column.</p><p>Values can be accessed in any test component in the same thread group, using the&nbsp;<a href="http://jmeter.apache.org/usermanual/functions.html">function syntax&nbsp;</a>: ${variable}.</p><p>See also the&nbsp;<a href="http://jmeter.apache.org/usermanual/component_reference.html#CSV_Data_Set_Config">CSV Data Set Config</a>&nbsp;element, which is more suitable for large numbers of parameters</p><p><strong>Control Panel</strong></p><div align="center"><img width="703" height="303" src="http://jmeter.apache.org/images/screenshots/user_params.png"  alt="" /></div><p><strong>Parameters</strong><a name="User_Parameters_parms" style="width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat;"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>Update Once Per Iteration</td><td>A flag to indicate whether the User Paramters element should update its variables only once per iteration. if you embed functions into the UP, then you may need greater control over how often the values of the variables are updated. Keep this box checked to ensure the values are updated each time through the UP's parent controller. Uncheck the box, and the UP will update the parameters for every sample request made within its&nbsp;<a href="http://jmeter.apache.org/usermanual/test_plan.html#scoping_rules">scope&nbsp;</a>.</td><td>Yes</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr><td><br /></td></tr></tbody></table><img src ="http://www.blogjava.net/qileilove/aggbug/410580.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-04 11:19 <a href="http://www.blogjava.net/qileilove/articles/410580.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jmeter之定时器</title><link>http://www.blogjava.net/qileilove/articles/410532.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Mon, 03 Mar 2014 03:55:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410532.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410532.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410532.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410532.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410532.html</trackback:ping><description><![CDATA[<table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="BeanShell_Timer">18.6.6 BeanShell Timer</a></h3></td></tr><tr><td><p>The BeanShell Timer can be used to generate a delay.</p><p><strong>For full details on using BeanShell, please see the&nbsp;<a href="http://www.beanshell.org/">BeanShell website.</a></strong></p><p>The test element supports the ThreadListener and TestListener methods. These should be defined in the initialisation file. See the file BeanShellListeners.bshrc for example definitions.</p><p><strong>Control Panel</strong></p><div align="center"><img width="846" height="636" src="http://jmeter.apache.org/images/screenshots/timers/beanshell_timer.png"  alt="" /></div><p><strong>Parameters</strong><a name="BeanShell_Timer_parms"></a></p>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree. The name is stored in the script variable Label</td><td>No</td></tr><tr><td>Reset bsh.Interpreter before each call</td><td>If this option is selected, then the interpreter will be recreated for each sample. This may be necessary for some long running scripts. For further information, see&nbsp;<a href="http://jmeter.apache.org/usermanual/best-practices#bsh_scripting">Best Practices - BeanShell scripting&nbsp;</a>.</td><td>Yes</td></tr><tr><td>Parameters</td><td>Parameters to pass to the BeanShell script. The parameters are stored in the following variables:<ul><li>Parameters - string containing the parameters as a single variable</li><li>bsh.args - String array containing parameters, split on white-space</li></ul></td><td>No</td></tr><tr><td>Script file</td><td>A file containing the BeanShell script to run. The file name is stored in the script variable FileName The return value is used as the number of milliseconds to wait.</td><td>No</td></tr><tr><td>Script</td><td>The BeanShell script. The return value is used as the number of milliseconds to wait.</td><td>Yes (unless script file is provided)</td></tr></tbody></table><p>&nbsp;</p><p>Before invoking the script, some variables are set up in the BeanShell interpreter:</p><ul><li>log - (Logger) - can be used to write to the log file</li><li>ctx - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html">JMeterContext&nbsp;</a>) - gives access to the context</li><li>vars - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html">JMeterVariables&nbsp;</a>) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object());</li><li>props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");</li><li>prev - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html">SampleResult&nbsp;</a>) - gives access to the previous SampleResult (if any)</li></ul><p>For details of all the methods available on each of the above variables, please check the Javadoc</p><p>If the property&nbsp;<strong>beanshell.timer.init&nbsp;</strong>is defined, this is used to load an initialisation file, which can be used to define methods etc for use in the BeanShell script.</p></td></tr></tbody></table><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="BSF_Timer">18.6.7 BSF Timer</a></h3></td></tr><tr><td><p>The BSF Timer can be used to generate a delay using a BSF scripting language.</p><p><strong>Control Panel</strong></p><div align="center"><img width="844" height="636" src="http://jmeter.apache.org/images/screenshots/timers/bsf_timer.png"  alt="" /></div><p><strong>Parameters</strong><a name="BSF_Timer_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this element that is shown in the tree.</td><td>No</td></tr><tr><td>ScriptLanguage</td><td>The scripting language to be used.</td><td>Yes</td></tr><tr><td>Parameters</td><td>Parameters to pass to the script. The parameters are stored in the following variables:<ul><li>Parameters - string containing the parameters as a single variable</li><li>args - String array containing parameters, split on white-space</li></ul></td><td>No</td></tr><tr><td>Script file</td><td>A file containing the script to run, if a relative file path is used, then it will be relative to directory referenced by "user.dir" System property The return value is converted to a long integer and used as the number of milliseconds to wait.</td><td>No</td></tr><tr><td>Script</td><td>The script. The return value is used as the number of milliseconds to wait.</td><td>Yes (unless script file is provided)</td></tr></tbody></table><p>&nbsp;</p><p>Before invoking the script, some variables are set up in the script interpreter:</p><ul><li>log - (Logger) - can be used to write to the log file</li><li>ctx - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html">JMeterContext&nbsp;</a>) - gives access to the context</li><li>vars - (&nbsp;<a href="http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html">JMeterVariables&nbsp;</a>) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object());</li><li>props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");</li><li>sampler - the current Sampler</li><li>Label - the name of the Timer</li><li>Filename - the file name (if any)</li><li>OUT - System.out</li></ul><p>For details of all the methods available on each of the above variables, please check the Javadoc</p></td></tr></tbody></table><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Constant_Throughput_Timer">18.6.4 Constant Throughput Timer</a></h3></td></tr><tr><td><p>This timer introduces variable pauses, calculated to keep the total throughput (in terms of samples per minute) as close as possible to a give figure. Of course the throughput will be lower if the server is not capable of handling it, or if other timers or time-consuming test elements prevent it.</p><p>N.B. although the Timer is called the Constant Throughput timer, the throughput value does not need to be constant. It can be defined in terms of a variable or function call, and the value can be changed during a test. The value can be changed in various ways:</p><ul><li>using a counter variable</li><li>using a JavaScript or BeanShell function to provide a changing value</li><li>using the remote BeanShell server to change a JMeter property</li></ul><p>See&nbsp;<a href="http://jmeter.apache.org/usermanual/best-practices.html">Best Practices&nbsp;</a>for further details. Note that the throughput value should not be changed too often during a test - it will take a while for the new value to take effect.</p><p><strong>Control Panel</strong></p><div align="center"><img width="636" height="146" src="http://jmeter.apache.org/images/screenshots/timers/constant_throughput_timer.png"  alt="" /></div><p><strong>Parameters</strong><a name="Constant_Throughput_Timer_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this timer that is shown in the tree.</td><td>No</td></tr><tr><td>Target Throughput</td><td>Throughput we want the timer to try to generate.</td><td>Yes</td></tr><tr><td>Calculate Throughput based on</td><td><ul><li>this thread only - each thread will try to maintain the target throughput. The overall throughput will be proportional to the number of active threads.</li><li>all active threads in current thread group - the target throughput is divided amongst all the active threads in the group. Each thread will delay as needed, based on when it last ran.</li><li>all active threads - the target throughput is divided amongst all the active threads in all Thread Groups. Each thread will delay as needed, based on when it last ran. In this case, each other Thread Group will need a Constant Throughput timer with the same settings.</li><li>all active threads in current thread group (shared) - as above, but each thread is delayed based on when any thread in the group last ran.</li><li>all active threads (shared) - as above; each thread is delayed based on when any thread last ran.</li></ul></td><td>Yes</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr><td><br /></td></tr></tbody></table><hr style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Poisson_Random_Timer">18.6.9 Poisson Random Timer</a></h3></td></tr><tr><td><p>This timer pauses each thread request for a random amount of time, with most of the time intervals ocurring near a particular value. The total delay is the sum of the Poisson distributed value, and the offset value.</p><p><strong>Control Panel</strong></p><div align="center"><img width="341" height="182" src="http://jmeter.apache.org/images/screenshots/timers/poisson_random_timer.png"  alt="" /></div><p><strong>Parameters</strong><a name="Poisson_Random_Timer_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this timer that is shown in the tree</td><td>No</td></tr><tr><td>Lambda</td><td>Lambda value in milliseconds.</td><td>Yes</td></tr><tr><td>Constant Delay Offset</td><td>Number of milliseconds to pause in addition to the random delay.</td><td>Yes</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr><td><br /></td></tr></tbody></table><hr style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;" /><a href="http://jmeter.apache.org/usermanual/component_reference.html#" style="font-family: Simsun; font-size: medium; line-height: normal; background-color: #ffffff;">^</a><table border="0" cellspacing="0" cellpadding="2" style="color: #000000;"><tbody><tr><td><h3><a name="Synchronizing_Timer">18.6.5 Synchronizing Timer</a></h3></td></tr><tr><td><p>The purpose of the SyncTimer is to block threads until X number of threads have been blocked, and then they are all released at once. A SyncTimer can thus create large instant loads at various points of the test plan.</p><p><strong>Control Panel</strong></p><div align="center"><img width="415" height="125" src="http://jmeter.apache.org/images/screenshots/timers/sync_timer.png"  alt="" /></div><p><strong>Parameters</strong><a name="Synchronizing_Timer_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this timer that is shown in the tree.</td><td>No</td></tr><tr><td>Number of Simultaneous Users to Group by</td><td>Number of threads to release at once. Setting it to 0 is equivalent to setting it to Number of threads in Thread Group.</td><td>Yes</td></tr></tbody></table><p>&nbsp;</p></td></tr><tr></tr></tbody></table><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Uniform_Random_Timer">18.6.3 Uniform Random Timer</a></h3></td></tr><tr><td><p>This timer pauses each thread request for a random amount of time, with each time interval having the same probability of occurring. The total delay is the sum of the random value and the offset value.</p><p><strong>Control Panel</strong></p><div align="center"><img width="372" height="157" src="http://jmeter.apache.org/images/screenshots/timers/uniform_random_timer.png"  alt="" /></div><p><strong>Parameters</strong><a name="Uniform_Random_Timer_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this timer that is shown in the tree.</td><td>No</td></tr><tr><td>Random Delay Maximum</td><td>Maxium random number of milliseconds to pause.</td><td>Yes</td></tr><tr><td>Constant Delay Offset</td><td>Number of milliseconds to pause in addition to the random delay.</td><td>Yes</td></tr></tbody></table></td></tr></tbody></table><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Constant_Timer">18.6.1 Constant Timer</a></h3></td></tr><tr><td><p>If you want to have each thread pause for the same amount of time between requests, use this timer.</p><p><strong>Control Panel</strong></p><div align="center"><img width="372" height="100" src="http://jmeter.apache.org/images/screenshots/timers/constant_timer.png"  alt="" /></div><p><strong>Parameters</strong><a name="Constant_Timer_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this timer that is shown in the tree.</td><td>No</td></tr><tr><td>Thread Delay</td><td>Number of milliseconds to pause.</td><td>Yes</td></tr></tbody></table></td></tr></tbody></table><br /><br /><br /><table border="0" cellspacing="0" cellpadding="2" style="color: #000000; font-family: Simsun; background-color: #ffffff;"><tbody><tr><td><h3><a name="Gaussian_Random_Timer">18.6.2 Gaussian Random Timer</a></h3></td></tr><tr><td><p>This timer pauses each thread request for a random amount of time, with most of the time intervals ocurring near a particular value. The total delay is the sum of the Gaussian distributed value (with mean 0.0 and standard deviation 1.0) times the deviation value you specify, and the offset value. Another way to explain it, in Gaussian Random Timer, the variation around constant offset has a gaussian curve distribution.</p><p><strong>Control Panel</strong></p><div align="center"><img width="372" height="156" src="http://jmeter.apache.org/images/screenshots/timers/gauss_random_timer.png"  alt="" /></div><p><strong>Parameters</strong><a name="Gaussian_Random_Timer_parms"></a></p><table border="1" cellspacing="0" cellpadding="2"><tbody><tr><th>Attribute</th><th>Description</th><th>Required</th></tr><tr><td>Name</td><td>Descriptive name for this timer that is shown in the tree</td><td>No</td></tr><tr><td>Deviation</td><td>Deviation in milliseconds.</td><td>Yes</td></tr><tr><td>Constant Delay Offset</td><td>Number of milliseconds to pause in addition to the random delay.</td><td>Yes</td></tr></tbody></table></td></tr></tbody></table><img src ="http://www.blogjava.net/qileilove/aggbug/410532.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-03 11:55 <a href="http://www.blogjava.net/qileilove/articles/410532.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jmeter之配置元件</title><link>http://www.blogjava.net/qileilove/articles/410452.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Fri, 28 Feb 2014 05:50:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410452.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410452.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410452.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410452.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410452.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: jmeter之配置元件利用Jmeter的http请求的时候，例如登陆操作，我们做普通用户名和密码作参数化，循环读取文本里的用户名和密码，可以添加CSV&nbsp;Data&nbsp;Set&nbsp;Config这个原件来控制。利用Jmeter的CSV&nbsp;Data&nbsp;Set&nbsp;Config，可以实现这个功能，具体如下：1.新建一个文本文件，里面保存要登录的用户名，密码，文件...&nbsp;&nbsp;<a href='http://www.blogjava.net/qileilove/articles/410452.html'>阅读全文</a><img src ="http://www.blogjava.net/qileilove/aggbug/410452.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-02-28 13:50 <a href="http://www.blogjava.net/qileilove/articles/410452.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jmeter之逻辑控制器</title><link>http://www.blogjava.net/qileilove/articles/410380.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Thu, 27 Feb 2014 03:31:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410380.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410380.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410380.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410380.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410380.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 测试片段（Test&nbsp;Fragment）&nbsp;　　测试片段是在2.5版本之后新加的一个选项。　　测试片段元素是控制器上的一个种特殊的线程组，它在测试树上与线程组处于一个层级。它与线程组有所不同，因为它不被执行，除非它是一个模块控制器或者是被控制器所引用时才会被执行。ForEach控制器ForEach控制器在用户自定义变量中读取一系列相关的变量。该控制器下的采样器或控制器都会被执行一次...&nbsp;&nbsp;<a href='http://www.blogjava.net/qileilove/articles/410380.html'>阅读全文</a><img src ="http://www.blogjava.net/qileilove/aggbug/410380.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-02-27 11:31 <a href="http://www.blogjava.net/qileilove/articles/410380.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jmeter之线程组</title><link>http://www.blogjava.net/qileilove/articles/410322.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Wed, 26 Feb 2014 03:26:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410322.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410322.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410322.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410322.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410322.html</trackback:ping><description><![CDATA[<p align="left" style="word-break: break-all; margin: 10px 0px; padding: 0px; line-height: 21.60000228881836px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　虽然有三个添加线程组的选项，名字不一样， 创建之后，其界面是完全一样的。之前的版本只有一个线程组的名字。现在多一个setUp theread Group 与terDown Thread Group</p><p align="left" style="word-break: break-all; margin: 10px 0px; padding: 0px; line-height: 21.60000228881836px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　1）setup thread group</p><p align="left" style="word-break: break-all; margin: 10px 0px; padding: 0px; line-height: 21.60000228881836px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　一种特殊类型的ThreadGroup的，可用于执行预测试操作。这些线程的行为完全像一个正常的线程组元件。不同的是，这些类型的线程执行测试前进行定期线程组的执行。</p><p align="left" style="word-break: break-all; margin: 10px 0px; padding: 0px; line-height: 21.60000228881836px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　2）teardown thread group</p><p align="left" style="word-break: break-all; margin: 10px 0px; padding: 0px; line-height: 21.60000228881836px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　一种特殊类型的ThreadGroup的，可用于执行测试后动作。这些线程的行为完全像一个正常的线程组元件。不同的是，这些类型的线程执行测试结束后执行定期的线程组。</p><p align="left" style="word-break: break-all; margin: 10px 0px; padding: 0px; line-height: 21.60000228881836px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　可能你还是不太理他们与普通的线程组有什么不同。 如果您用过junit，想必你不会对setup ，teardown这2个字眼陌生。 即时每用过，也没关系。 熟悉loadrunner的应该知道，loadrunner的脚本除了action里是真正的脚本核心内容，还有初始化&#8220;环境&#8221;的初始化脚本和测试完毕后对应的清除信息的脚本块。 那么这里 setup thread group 和 teardown thread group 就是分别指这两部分。&nbsp; 其实从本质上来看，他们并没有什么不同。</p><p align="left" style="word-break: break-all; margin: 10px 0px; padding: 0px; line-height: 21.60000228881836px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　3）thread group（线程组）</p><p align="left" style="word-break: break-all; margin: 10px 0px; padding: 0px; line-height: 21.60000228881836px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　这个就是我们通常添加运行的线程。通俗的讲一个线程组，可以看做一个虚拟用户组，线程组中的每个线程都可以理解为一个虚拟用户。线程组中包含的线程数量在测试执行过程中是不会发生改变的。<br /><br /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/jm1.jpg" width="1367" height="740" alt="" /><br /><br /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/jm2.jpg" width="1367" height="740" alt="" /><br /><br /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/jm3.jpg" width="1367" height="740" alt="" /><br /><br /><br /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/jm4.jpg" width="1367" height="740" alt="" /><br /><br /></p><img src ="http://www.blogjava.net/qileilove/aggbug/410322.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-02-26 11:26 <a href="http://www.blogjava.net/qileilove/articles/410322.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jmeter之测试计划组件</title><link>http://www.blogjava.net/qileilove/articles/410277.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Tue, 25 Feb 2014 03:02:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410277.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410277.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410277.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410277.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410277.html</trackback:ping><description><![CDATA[<br /><br /><br /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/test/jmeter1.jpg" width="1367" height="740" alt="" /><br /><br /><br /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/test/jmeter2.jpg" width="1367" height="740" alt="" /><br /><br /><br /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/test/jmeter3.jpg" width="1366" height="740" alt="" /><br /><br /><br /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/test/jmeter4.jpg" width="1367" height="740" alt="" /><br /><br /><br /><br /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/test/jmeter5.jpg" width="1367" height="740" alt="" /><br /><img src ="http://www.blogjava.net/qileilove/aggbug/410277.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-02-25 11:02 <a href="http://www.blogjava.net/qileilove/articles/410277.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jmeter 目录介绍</title><link>http://www.blogjava.net/qileilove/articles/410234.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Mon, 24 Feb 2014 03:02:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410234.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410234.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410234.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410234.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410234.html</trackback:ping><description><![CDATA[<h2><a id="viewpost1_TitleUrl" href="http://www.blogjava.net/qileilove/archive/2014/02/24/410233.html" style="color: #0066aa; text-decoration: none;">jmeter 目录介绍</a></h2><img src="http://www.blogjava.net/images/blogjava_net/qileilove/jmeter.jpg" width="804" height="604" alt="" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/jmeter1.jpg" width="804" height="604" alt="" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/jmeter2.jpg" width="804" height="604" alt="" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/jmeter4.jpg" width="804" height="604" alt="" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/jmeter3.jpg" width="804" height="604" alt="" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><img src="http://www.blogjava.net/images/blogjava_net/qileilove/jmeter5.jpg" width="1367" height="740" alt="" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><br style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 16px; line-height: normal;" /><img src ="http://www.blogjava.net/qileilove/aggbug/410234.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-02-24 11:02 <a href="http://www.blogjava.net/qileilove/articles/410234.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Jmeter常用组件介绍</title><link>http://www.blogjava.net/qileilove/articles/410152.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Fri, 21 Feb 2014 04:25:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410152.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410152.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410152.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410152.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410152.html</trackback:ping><description><![CDATA[<p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.59375px;">测试计划：整个测试计划；</span><br />&nbsp; 1 线程组</p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 每个测试都会用到的，如前所说，这个是用来设置并发访问线程数量的。<br /><span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.59375px;">线程组：所有的任务都是基于线程组，开通多少个线程就代表有多少个并发用户；<br /></span><span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.59375px;">　JMeter的组件主要包含：逻辑控制器，配置元件，定时器，前置处理器，Sampler，后置处理器，断言，监听器。刚开始</span><a href="http://www.blogjava.net/qileilove/archive/2013/11/28/406930.html" target="_self" style="color: #202859; text-decoration: none; font-family: Arial, Helvetica, sans-serif; font-size: 12px; word-break: break-all; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">学习</strong></u></a><span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.59375px;">，只能对他们有个大概的了解，以后慢慢使用了就会更熟悉些。<br /><br /></span></p><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">1、逻辑控制器(LogicController)</strong></div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　逻辑控制器主要用来控制JMeter发送请求（也就是采样器）的处理顺序，例如，它可以使从属于它一组请求它与Sampler结合使用可以模拟复杂的请求序列。</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=43292" target="_blank" style="color: #202859; text-decoration: none; word-break: break-all; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/11/14982672_201311261438441NLDf.jpg" border="0" alt="" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;" /></a></div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=43293" target="_blank" style="color: #202859; text-decoration: none; word-break: break-all; line-height: normal !important;"><font color="#202859"><img src="http://www.51testing.com/attachments/2013/11/14982672_201311261438442qzMD.jpg" border="0" alt="" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;" /></font><br /><br /></a><a href="http://www.51testing.com/batch.download.php?aid=43293" target="_blank" style="color: #0066aa; text-decoration: none;"><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　<strong style="word-break: break-all; line-height: normal !important;">2、采样器(Sampler)</strong></div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　采样器也就是发送一个具体的请求到指定服务器，等待服务器的请求。一般，采样器会按照其在测试树中的顺序去执行，但是也会根据逻辑控制器来改变运行的次数和顺序。JMeter 采样器包含：</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　FTP Request</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　HTTP Request</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　JDBC Request</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　Java object request</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　LDAP Request</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　SOAP/XML-RPC Request</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　WebService (SOAP) Request</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　<strong style="word-break: break-all; line-height: normal !important;">3、配置元件(Config Element)</strong></div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　配置元件和它的名字一样，只是配置一些默认的属性和信息，它不向服务器发送任何的请求。配置元件仅对其所在的测试树分支有效。例如，HTTP请求默认值设置了服务器的名称，那么它所在的测试分支内的HTTP请求的服务器名称都是这个服务器，HTTP请求仅设置路径就可以访问网页了。配置元件主要有：</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　CSV Data Set Config</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　FTP请求缺省值</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　HTTPCacheManager</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　HTTPCookie管理</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　HTTP信息头管理器</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　HTTP授权管理器</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　HTTP　请求默认值</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　JAVA请求默认值</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　LDAP请求默认值</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　TCP请求默认值</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　登录配置元件</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　计数器</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　但是有个例外，配置元件"用户定义的参数"无论它处于测试树的哪个位置，总是在测试的初始阶段执行。所以最好把它放在线程组的开始部分。</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　<strong style="word-break: break-all; line-height: normal !important;">4、监听器（Listener）</strong></div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　监听器是把测试结果用数据进行处理并展示出来。 查看结果树，用表格查看结果，图形结果、、聚合报告，都是我们经常用到的元件。</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　<strong style="word-break: break-all; line-height: normal !important;">5、断言（Assertions）</strong></div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　用于检查测试中得到的数据和我们预期的结果是否相同。</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　<strong style="word-break: break-all; line-height: normal !important;">6、前置处理器（Per Processors）</strong></div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　在发出请求之前对请求进行特殊的处理。例如，HTTP URL重写修复符则可以实现URL重写，当RUL中有sessionID 一类的session信息时，可以通过该处理器填充发出请求的实际的sessionID 。</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　<strong style="word-break: break-all; line-height: normal !important;">7、后置处理器（Post Processors）</strong></div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　对采样器 发出请求后得到的服务器响应进行处理。一般用来提取响应中的特定数据。例如，XPath &nbsp;Extractor 可以提取响应数据中通过给定XPath 值获得的数据。</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　元件的执行顺序</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　在同一作用域名范围内，测试计划中的元件按照如下顺序执行。</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　（1）配置元件（config elements ）</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　（2）前置处理程序（Per-processors）</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　（3）定时器（timers ）</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　（4）取样器（Sampler）</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　（5）后置处理程序（Post-processors） （除非Sampler 得到的返回结果为空）。</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　（6）断言（Assertions）（除非Sampler 得到的返回结果为空）。</div><div style="word-break: break-all; margin: 10px 0px; color: #333333;">　　（7）监听器（Listeners）（除非Sampler 得到的返回结果为空）。</div></a></div><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.59375px;"><br /></span></p><img src ="http://www.blogjava.net/qileilove/aggbug/410152.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-02-21 12:25 <a href="http://www.blogjava.net/qileilove/articles/410152.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jmeter系列之初识jmeter</title><link>http://www.blogjava.net/qileilove/articles/410086.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Thu, 20 Feb 2014 03:08:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/articles/410086.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/410086.html</wfw:comment><comments>http://www.blogjava.net/qileilove/articles/410086.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/410086.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/410086.html</trackback:ping><description><![CDATA[既然要做一整个系列文章~<br />那么久从头开始介绍<br />以下是百度百科中的<br /><h1><div style="float: left; height: 34px; padding-bottom: 5px;">Jmeter</div><div bk3-title-wrap"="" style="background-image: url(http://baike.bdimg.com/static/lemma/view3/img/title/btn_bg_e97a70cb.png); margin: 6px 0px 0px 10px; font-size: 12px; float: left; font-family: 宋体; background-position: initial initial; background-repeat: repeat no-repeat;"><a id="lemma-edit" data-edit-id="171821" data-title="编辑" style="color: #a0a0a0; font-size: 12px; padding-left: 29px; cursor: pointer; line-height: 25px; display: block; width: 35px; height: 25px; border: 1px solid #e6e6e6; background-image: url(http://baike.bdimg.com/static/lemma/view3/img/icon-view_185c1484.png); background-color: #fdfdfd; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding-right: 0px; background-position: -75px -164px; background-repeat: no-repeat no-repeat;">编辑</a></div></h1><div style="clear: both; font-size: 0px; line-height: 0; height: 0px; visibility: visible; font-family: arial, 宋体, sans-serif; background-color: #ffffff;"></div><div id="card-container" style="margin-bottom: 18px; font-family: arial, 宋体, sans-serif; font-size: 14px; background-color: #ffffff; clear: both;"><div nslog-area=""  clearfix"="" data-nslog-type="72" style="clear: both; line-height: 25px; font-size: 14px; color: #333333; margin-bottom: 18px;"><div><div style="margin-bottom: 5px; text-indent: 2em; line-height: 24px;">Apache JMeter是Apache组织开发的基于Java的压力测试工具。用于对<a target="_blank" href="http://baike.baidu.com/view/37.htm" style="text-decoration: none; color: #136ec2;">软件</a>做压力测试，它最初被设计用于<a target="_blank" href="http://baike.baidu.com/view/2022227.htm" style="text-decoration: none; color: #136ec2;">Web应用测试</a>但后来扩展到其他测试领域。 它可以用于测试<a target="_blank" href="http://baike.baidu.com/view/612026.htm" style="text-decoration: none; color: #136ec2;">静态</a>和动态资源例如静态文件、Java&nbsp;<a target="_blank" href="http://baike.baidu.com/view/229606.htm" style="text-decoration: none; color: #136ec2;">小服务程序</a>、CGI&nbsp;<a target="_blank" href="http://baike.baidu.com/view/54.htm" style="text-decoration: none; color: #136ec2;">脚本</a>、Java 对象、数据库， FTP 服务器， 等等。JMeter 可以用于对服务器、网络或对象模拟巨大的负载，来在不同压力类别下测试它们的强度和分析整体性能。另外，JMeter能够对应用程序做功能/<a target="_blank" href="http://baike.baidu.com/view/106720.htm" style="text-decoration: none; color: #136ec2;">回归测试</a>，通过创建带有断言的<a target="_blank" href="http://baike.baidu.com/view/54.htm" style="text-decoration: none; color: #136ec2;">脚本</a>来验证你的程序返回了你期望的结果。为了最大限度的灵活性，JMeter允许<a target="_blank" href="http://baike.baidu.com/view/1091115.htm" style="text-decoration: none; color: #136ec2;">使用正则表达式</a>创建断言。</div><div style="margin-bottom: 5px; text-indent: 2em; line-height: 24px;">Apache jmeter 可以用于对<a target="_blank" href="http://baike.baidu.com/view/612026.htm" style="text-decoration: none; color: #136ec2;">静态</a>的和动态的资源（文件，Servlet，Perl<a target="_blank" href="http://baike.baidu.com/view/54.htm" style="text-decoration: none; color: #136ec2;">脚本</a>，java 对象，数据库和查询，<a target="_blank" href="http://baike.baidu.com/view/106754.htm" style="text-decoration: none; color: #136ec2;">FTP服务器</a>等等）的性能进行测试。它可以用于对服务器，网络 或对象模拟繁重的负载来测试它们的强度或分析不同压力类型下的整体性能。你可以使用它做性能的图形分析或在大并发<a target="_blank" href="http://baike.baidu.com/view/651437.htm" style="text-decoration: none; color: #136ec2;">负载测试</a>你的服务器/<a target="_blank" href="http://baike.baidu.com/view/54.htm" style="text-decoration: none; color: #136ec2;">脚本</a>/对象。</div></div></div></div><div nslog-area=""  log-set-param"="" log-set-param="catalogshow" data-nslog-type="1016" id="catalog-0" data-subindex="0" style="z-index: 0; position: relative; background-image: url(http://baike.baidu.com/static/lemma/view3/img/cate_top_15.png); background-color: #fbfbfb; width: 310px; overflow: hidden; margin-top: 30px; padding-top: 6px; clear: both; font-family: arial, 宋体, sans-serif; font-size: 14px; background-position: 0px 0px; background-repeat: no-repeat no-repeat;"><h2><span style="display: block; width: 64px; height: 48px; position: absolute; top: 12px; right: -1px; background-color: #64a0de; color: #ffffff; border-right-width: 3px; border-right-style: solid; border-right-color: #4c88c7; font-size: 18px; line-height: 48px; zoom: 1; background-position: initial initial; background-repeat: initial initial;">目录</span></h2><dl id="catalog-holder-0"  hideholder"="" style="margin: 0px; padding: 6px 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #ebebeb; background-color: #ffffff; min-height: 60px; overflow: hidden; height: 157px; background-position: initial initial; background-repeat: initial initial;"><dd 0"="" style="margin: 3px 0px 0px; padding: 2px 0px; line-height: 20px;"><p style="margin: 0px; padding: 0px 0px 0px 25px; position: relative; zoom: 1;"><span style="position: absolute; left: 0px; top: 0px; width: 18px; color: #63a0df; padding-right: 8px; text-align: right; display: inline-block;">1</span><a href="http://baike.baidu.com/link?url=nNSoqa5scP7zoY7OUE3xrl4aWw1v_2Ca2V0NazrKB0V5wFp0y1ggLoxA-oYhbL5T#1" catalog="true" name="STAT_ONCLICK_UNSUBMIT_CATALOG" style="text-decoration: none; color: #136ec2; padding-right: 10px; font-family: 微软雅黑, 黑体;">作用特性</a></p></dd><dd er=""  28"="" style="margin: 0px; padding: 3px 0px 2px 26px; line-height: 16px; font-size: 12px; color: #333333;"><span style="color: #cccccc; padding-right: 5px;">&#9642;</span>&nbsp;<a href="http://baike.baidu.com/link?url=nNSoqa5scP7zoY7OUE3xrl4aWw1v_2Ca2V0NazrKB0V5wFp0y1ggLoxA-oYhbL5T#1_1" catalog="true" style="text-decoration: none; color: #333333;">JMeter的作用</a></dd><dd er=""  49"="" style="margin: 0px; padding: 3px 0px 2px 26px; line-height: 16px; font-size: 12px; color: #333333;"><span style="color: #cccccc; padding-right: 5px;">&#9642;</span>&nbsp;<a href="http://baike.baidu.com/link?url=nNSoqa5scP7zoY7OUE3xrl4aWw1v_2Ca2V0NazrKB0V5wFp0y1ggLoxA-oYhbL5T#1_2" catalog="true" style="text-decoration: none; color: #333333;">JMeter的高可扩展性</a></dd><dd 70"="" style="margin: 6px 0px 0px; padding: 2px 0px; line-height: 20px;"><p style="margin: 0px; padding: 0px 0px 0px 25px; position: relative; zoom: 1;"><span style="position: absolute; left: 0px; top: 0px; width: 18px; color: #63a0df; padding-right: 8px; text-align: right; display: inline-block;">2</span><a href="http://baike.baidu.com/link?url=nNSoqa5scP7zoY7OUE3xrl4aWw1v_2Ca2V0NazrKB0V5wFp0y1ggLoxA-oYhbL5T#2" catalog="true" name="STAT_ONCLICK_UNSUBMIT_CATALOG" style="text-decoration: none; color: #136ec2; padding-right: 10px; font-family: 微软雅黑, 黑体;">意义</a></p></dd><dd 98"="" style="margin: 3px 0px 0px; padding: 2px 0px; line-height: 20px;"><p style="margin: 0px; padding: 0px 0px 0px 25px; position: relative; zoom: 1;"><span style="position: absolute; left: 0px; top: 0px; width: 18px; color: #63a0df; padding-right: 8px; text-align: right; display: inline-block;">3</span><a href="http://baike.baidu.com/link?url=nNSoqa5scP7zoY7OUE3xrl4aWw1v_2Ca2V0NazrKB0V5wFp0y1ggLoxA-oYhbL5T#3" catalog="true" name="STAT_ONCLICK_UNSUBMIT_CATALOG" style="text-decoration: none; color: #136ec2; padding-right: 10px; font-family: 微软雅黑, 黑体;">历史</a></p></dd><dd 126"="" style="margin: 3px 0px 0px; padding: 2px 0px; line-height: 20px;"><p style="margin: 0px; padding: 0px 0px 0px 25px; position: relative; zoom: 1;"><span style="position: absolute; left: 0px; top: 0px; width: 18px; color: #63a0df; padding-right: 8px; text-align: right; display: inline-block;">4</span><a href="http://baike.baidu.com/link?url=nNSoqa5scP7zoY7OUE3xrl4aWw1v_2Ca2V0NazrKB0V5wFp0y1ggLoxA-oYhbL5T#4" catalog="true" name="STAT_ONCLICK_UNSUBMIT_CATALOG" style="text-decoration: none; color: #136ec2; padding-right: 10px; font-family: 微软雅黑, 黑体;">远景</a></p></dd></dl><div id="lemma-catalog-bottombg" style="height: 6px; font-size: 6px; width: 310px; line-height: 6px; background-image: url(http://baike.baidu.com/static/lemma/view3/img/cate_bottom_18.png); background-color: transparent; clear: both; background-position: 0px 0px; background-repeat: no-repeat no-repeat;"></div></div><div style="clear: both; font-size: 0px; line-height: 0; height: 0px; visibility: visible; font-family: arial, 宋体, sans-serif; background-color: #ffffff;"></div><div id="lemmaContent-0"  rainbowlemma--"="" style="overflow: hidden; float: left; outline: 0px; padding-bottom: 16px; width: 790px; position: relative; left: -30px; padding-left: 30px; font-family: arial, 宋体, sans-serif; font-size: 14px; background-color: #ffffff;"><h2><span style="width: 25px; height: 24px; font-size: 16px; display: block; float: left; margin: 1px 0px 0px; background-color: #519cea; color: #ffffff; text-align: center; border-top-left-radius: 0px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 0px;">1</span><a name="1" style="color: rgb(19, 110, 194); position: absolute; top: -50px; display: block;"></a><a name="sub171821_1" style="color: rgb(19, 110, 194); position: absolute; top: -50px; display: block;"></a><span style="display: block; float: left; padding: 0px 8px 0px 5px;">作用特性</span><span editable-title"="" data-edit-id="171821:171821:1" style="display: block; float: right; padding: 6px 0px 0px 8px; margin-left: 10px;"><a href="http://baike.baidu.com/link?url=nNSoqa5scP7zoY7OUE3xrl4aWw1v_2Ca2V0NazrKB0V5wFp0y1ggLoxA-oYhbL5T#" title="编辑本段" style="text-decoration: none; color: #888888; height: 15px; line-height: 16px; padding-left: 18px; background-image: url(http://baike.bdimg.com/static/lemma/view3/img/icon-view_4b787901.gif); background-color: transparent; font-size: 12px; font-family: 宋体; display: block; background-position: -85px 1px; background-repeat: no-repeat no-repeat;">编辑</a></span></h2><h3><a name="1_1" style="color: rgb(19, 110, 194); position: relative; top: -50px; display: block;"></a><a name="sub171821_1_1" style="color: rgb(19, 110, 194); position: relative; top: -50px; display: block;"></a>JMeter的作用</h3><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">1.能够对HTTP和FTP服务器进行压力和<a target="_blank" href="http://baike.baidu.com/view/106187.htm" style="text-decoration: none; color: #136ec2;">性能测试</a>， 也可以对任何数据库进行同样的测试（通过JDBC）。</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">2.完全的可移植性和100% 纯java。</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">3.完全 Swing 和轻量组件支持（<a target="_blank" href="http://baike.baidu.com/view/176610.htm" style="text-decoration: none; color: #136ec2;">预编译</a>的JAR使用 javax.swing.*)包。</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">4.完全多线程 框架允许通过多个线程并发取样和 通过单独的<a target="_blank" href="http://baike.baidu.com/view/6427102.htm" style="text-decoration: none; color: #136ec2;">线程组</a>对不同的功能同时取样。</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">5.精心的GUI设计允许快速操作和更精确的计时。</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">6.缓存和离线分析/回放测试结果。</div><h3><a name="1_2" style="color: rgb(19, 110, 194); position: relative; top: -50px; display: block;"></a><a name="sub171821_1_2" style="color: rgb(19, 110, 194); position: relative; top: -50px; display: block;"></a>JMeter的高可扩展性</h3><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">1.可链接的取样器允许无限制的测试能力。</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">2.各种负载统计表和可链接的<a target="_blank" href="http://baike.baidu.com/view/928508.htm" style="text-decoration: none; color: #136ec2;">计时器</a>可供选择。</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">3.数据分析和可视化<a target="_blank" href="http://baike.baidu.com/view/18979.htm" style="text-decoration: none; color: #136ec2;">插件</a>提供了很好的可扩展性以及个性化。</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">4.具有提供动态输入到测试的功能（包括Javascrīpt）。</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">5.支持<a target="_blank" href="http://baike.baidu.com/view/54.htm" style="text-decoration: none; color: #136ec2;">脚本</a>变成的取样器（在1.9.2及以上版本支持BeanShell）。</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">在设计阶段，JMeter能够充当HTTP PROXY（代理）来记录IE/NETSCAPE的<a target="_blank" href="http://baike.baidu.com/view/641736.htm" style="text-decoration: none; color: #136ec2;">HTTP请求</a>，也可以记录apache等WebServer的log文件来重现HTTP流量。当这些HTTP<a target="_blank" href="http://baike.baidu.com/view/930.htm" style="text-decoration: none; color: #136ec2;">客户端</a>请求被记录以后，测试运行时可以方便的设置重复次数和并发度（<a target="_blank" href="http://baike.baidu.com/view/1410605.htm" style="text-decoration: none; color: #136ec2;">线程数</a>）来产生巨大的流量。JMeter还提供可视化组件以及<a target="_blank" href="http://baike.baidu.com/view/4309835.htm" style="text-decoration: none; color: #136ec2;">报表工具</a>把量服务器在不同压力下的性能展现出来。</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">相比其他HTTP测试工具,JMeter最主要的特点在于扩展性强。JMeter能够自动扫描其lib/ext子目录下.jar文件中的<a target="_blank" href="http://baike.baidu.com/view/18979.htm" style="text-decoration: none; color: #136ec2;">插件</a>，并且将其装载到内存，让用户通过不同的菜单调用。</div><h2><span style="width: 25px; height: 24px; font-size: 16px; display: block; float: left; margin: 1px 0px 0px; background-color: #519cea; color: #ffffff; text-align: center; border-top-left-radius: 0px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 0px;">2</span><a name="2" style="color: rgb(19, 110, 194); position: absolute; top: -50px; display: block;"></a><a name="sub171821_2" style="color: rgb(19, 110, 194); position: absolute; top: -50px; display: block;"></a><span style="display: block; float: left; padding: 0px 8px 0px 5px;">意义</span><span editable-title"="" data-edit-id="171821:171821:2" style="display: block; float: right; padding: 6px 0px 0px 8px; margin-left: 10px;"><a href="http://baike.baidu.com/link?url=nNSoqa5scP7zoY7OUE3xrl4aWw1v_2Ca2V0NazrKB0V5wFp0y1ggLoxA-oYhbL5T#" title="编辑本段" style="text-decoration: none; color: #888888; height: 15px; line-height: 16px; padding-left: 18px; background-image: url(http://baike.bdimg.com/static/lemma/view3/img/icon-view_4b787901.gif); background-color: transparent; font-size: 12px; font-family: 宋体; display: block; background-position: -85px 1px; background-repeat: no-repeat no-repeat;">编辑</a></span></h2><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">1、Label： 定义的HTTP请求名称</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">2、Samples： 表示这次测试中一共发出了多少个请求</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">3、Average： 访问页面的平均响应时间</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">4、Min: 访问页面的最小响应时间</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">5、Max: 访问页面的最大响应时间</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">6、Error%： 错误的请求的数量/请求的总数</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">7、Throughput：每秒完成的请求数</div><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">8、KB/Sec： 每秒从服务器端接收到的数据量</div><h2><span style="width: 25px; height: 24px; font-size: 16px; display: block; float: left; margin: 1px 0px 0px; background-color: #519cea; color: #ffffff; text-align: center; border-top-left-radius: 0px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 0px;">3</span><a name="3" style="color: rgb(19, 110, 194); position: absolute; top: -50px; display: block;"></a><a name="sub171821_3" style="color: rgb(19, 110, 194); position: absolute; top: -50px; display: block;"></a><span style="display: block; float: left; padding: 0px 8px 0px 5px;">历史</span><span editable-title"="" data-edit-id="171821:171821:3" style="display: block; float: right; padding: 6px 0px 0px 8px; margin-left: 10px;"><a href="http://baike.baidu.com/link?url=nNSoqa5scP7zoY7OUE3xrl4aWw1v_2Ca2V0NazrKB0V5wFp0y1ggLoxA-oYhbL5T#" title="编辑本段" style="text-decoration: none; color: #888888; height: 15px; line-height: 16px; padding-left: 18px; background-image: url(http://baike.bdimg.com/static/lemma/view3/img/icon-view_4b787901.gif); background-color: transparent; font-size: 12px; font-family: 宋体; display: block; background-position: -85px 1px; background-repeat: no-repeat no-repeat;">编辑</a></span></h2><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">Apache Software Foundation 的 Stefano Mazzocchi 是JMeter的最初开发人员。他编写它主要用于测试Apache JServ的性能（一个后来被Apache Tomcat项目替代的项目）。我们重新设计了JMeter，增强了它的GUI和添加了<a target="_blank" href="http://baike.baidu.com/view/651435.htm" style="text-decoration: none; color: #136ec2;">功能测试</a>支持。</div><h2><span style="width: 25px; height: 24px; font-size: 16px; display: block; float: left; margin: 1px 0px 0px; background-color: #519cea; color: #ffffff; text-align: center; border-top-left-radius: 0px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 0px;">4</span><a name="4" style="color: rgb(19, 110, 194); position: absolute; top: -50px; display: block;"></a><a name="sub171821_4" style="color: rgb(19, 110, 194); position: absolute; top: -50px; display: block;"></a><span style="display: block; float: left; padding: 0px 8px 0px 5px;">远景</span><span editable-title"="" data-edit-id="171821:171821:4" style="display: block; float: right; padding: 6px 0px 0px 8px; margin-left: 10px;"><a href="http://baike.baidu.com/link?url=nNSoqa5scP7zoY7OUE3xrl4aWw1v_2Ca2V0NazrKB0V5wFp0y1ggLoxA-oYhbL5T#" title="编辑本段" style="text-decoration: none; color: #888888; height: 15px; line-height: 16px; padding-left: 18px; background-image: url(http://baike.bdimg.com/static/lemma/view3/img/icon-view_4b787901.gif); background-color: transparent; font-size: 12px; font-family: 宋体; display: block; background-position: -85px 1px; background-repeat: no-repeat no-repeat;">编辑</a></span></h2><div style="color: #333333; margin-bottom: 5px; text-indent: 2em;">我们希望看到随着开发人员利用<a target="_blank" href="http://baike.baidu.com/view/18979.htm" style="text-decoration: none; color: #136ec2;">插件</a>架构的优势，JMeter的能力能够迅速扩展。将来开发的主要目标是使得JMeter尽可能地变成一个有用的衰退测试工具，而不损失JMeter的压力测试能力。<br /><br /><br /><br />官网上 我们可以下载源码 进行二次开发 也可以下载编译好的文件 直接进行测试 &nbsp;还可以去google 大牛开发的jmeter一系列插件 进行类似loadrunner的场景及分析<br /><br /><div>http://jmeter.apache.org/</div>官网也有相应的用法介绍 &nbsp;只不过下来我们自己把它转换成自己的知识~ 今天简介到此 &nbsp;有兴趣的可以先了解下官网知识 明天我们来介绍整个工具的构成~</div></div><img src ="http://www.blogjava.net/qileilove/aggbug/410086.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-02-20 11:08 <a href="http://www.blogjava.net/qileilove/articles/410086.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>