<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} p {mso-margin-top-alt:auto; margin-right:0cm; mso-margin-bottom-alt:auto; margin-left:0cm; mso-pagination:widow-orphan; font-size:12.0pt; font-family:宋体; mso-bidi-font-family:宋体;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->
从核桃博客 转载,http://www.hetaoblog.com/?p=63
使用性能测试工具Grinder做性能测试
使用性能测试工具Grinder来测试Java API的性能1
之前在使用性能测试工具JMeter来测试网站性能1 介 绍了使用JMeter来测试网站性能,JMeter可以对有登陆验证的web项目进行测试,并且做一定的逻辑控制,多种输出方式和较为灵活的线程设置等。 虽然JMeter可以有一定的逻辑控制等方式,建立较复杂的测试逻辑;打开保存好的JMeter测试计划文件(.jmx)文件可以看到,本质 上,JMeter生成的脚本是xml格式的,通过xml来描述测试逻辑自然比较累赘,这里介绍另外一款测试工具, Grinder,通过Jython脚本的方式来描述测试逻辑,可以获得Python脚本的方便性和对Java API的完整支持;
Grinder也是sourceforge旗下的一个开源项目,地址是http://grinder.sourceforge.net ,当前版本是3.3. Grinder的整体架构如下:
使用说明,
- 将下载到本地后,解压,将“lib/grinder.jar”放到classpath,
- 到examples目录下,命令行下输入java net.grinder.Console,启动Console界面如下
- 到examples目录下,命令行下输入java net.grinder.Grinder,启动一个agent进程,如果看到如下信息,就说明Agent启动成功了:
10-1-4 21:19:52 (agent): The Grinder 3.3
10-1-4 21:19:52 (agent): connected to console at localhost/127.0.0.1:6372
10-1-4 21:19:52 (agent): waiting for console signal
- 点击Console界面上工具栏上第一个图标”启动worker进程“,然后点击结果tab,就可以看到类似下图的数据结果
说明:
1. grinder.properties配置
Grinder使用当前目录下的grinder.properties配置文件指定性能测试的相关设置,所有配置在example目录下有一个默认 文件,所有字段也都有一个默认值(比如grinder.threads,grinder.processes等),可以手动修改;
2. 使用的脚本
在example目录下的grinder.properties里面,脚本是如下指定的,
grinder.script = helloworld.py
也就是说,运行的是helloworld.py脚本,其内容是打印一句helloworld,可以在log目录目录下的 out_machine_name.log下看到输出,可以自己修改配置指定sample下的其他脚本,也可以编写自己的Jython脚本,测试各类 web项目、java项目,web service项目等;
对于统计的详细信息,可以查看在log目录下的data_machine_name.log的内容;