Jmeter 性能测试
运行 JMeter 脚本
在 GUI 模式下在 JMeter 上调试脚本,您可以在 GUI 模式下调试记录脚本,直到没有错误为止
在非 GUI 模式(命令行模式)下运行测试脚本推荐
jmeter -n -t ..\extras\Test.jmx -l Test.jtl
在 Jenkins 上运行 JMeter 脚本
需要工具
- Jmeter - Web 请求负载测试
- Jmeter 插件:ServerAgent-2.2.1 - 与标准集一起使用的 PerfMon 代理
测试服务器
两个虚拟机
- 被测系统
- Jmeter 执行机,这个服务器也是 Jenkins 服务器
实行
开发测试脚本
Record Scripts - 使用 JMeter 的 HTTP(S) Test Script Recorder,请参考这个官方文档 https://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.html
创建 Jenkins 作业以运行 JMeter 脚本
1、新建项目->选择 Freestyle 项目
2、添加构建步骤->执行 Windows 批处理命令
//access to jenkins jobs workspace, empty the last test results
cmd
cd C:\Users\peter\.jenkins\jobs\TEST-122 Upload large data\workspace
del /Q "jtl"\*
del /Q "PerfMon Metrics Collector"\*
3、添加构建步骤->执行Windows批处理命令
//add first run jmeter script command, if you want run others script you can continue to add "Execute Windows batch command"
jmeter -n -t script/UploadLargeData-1.jmx -l jtl/UploadLargeData-1.jtl
4、配置构建电子邮件 - 配置系统
//Configure System, Extended E-mail Notification
SMTP server: smtp.gmail.com
//Job Configure, Enable "Editable Email Notification"
Project Recipient List: xianpeng.shen@gmail.com
Project Reply-To List: $DEFAULT_REPLYTO
Content Type: HTML (text/html)
Default Subject:$DEFAULT_SUBJECT
Default Content: ${SCRIPT, template="groovy-html.template"}
//Advance setting
Triggers: Always
Send to Recipient List
生成测试报告
JMeter->Add listener->add jp@gc - PerfMon Metrics Collector,浏览 Test.jtl,在图表上点击右键 Export to CSV
分析测试结果
介绍测试场景
使用1、5、10、20、30、(50)个用户加载测试,记录每组用户测试结果
词汇表
- Sample(label) - 这表示每个请求的虚拟用户数。
- 平均 - 这是所有样本执行特定标签所花费的平均时间
- 中位数 - 是将样本分成相等的两半的数字。
- %_line - 90%、95%、99% 的样本低于该值。
- Min - 特定标签的样本所用的最短时间。
- Max - 样本为特定标签花费的最长时间。
- Error% - 失败测试的百分比。
- 吞吐量 - 您的服务器每秒处理多少请求。越大越好。
- KB/Sec - 它是以每秒千字节为单位测量的吞吐量。
- 示例:各场景测试结果如下表
用户 | # 样本 | 平均的 | 中位数 | 90% 线 | 95% 线 | 最小值 | 最大限度 | 错误 % | 吞吐量 | 已收到 | 发送 KB/秒 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 31 | 348 | 345 | 452 | 517 | 773 | 5 | 773 | 0.00% | 2.85215 | 2.5 | 0 |
5 | 155 | 1166 | 1164 | 1414 | 1602 | 1639 | 9 | 1821 | 0.00% | 4.26445 | 3.73 | 0 |
10 | 310 | 2275 | 2299 | 2687 | 2954 | 3671 | 20 | 4104 | 0.00% | 4.38547 | 3.84 | 0 |
20 | 620 | 4479 | 4620 | 5113 | 6152 | 6435 | 39 | 6571 | 0.00% | 4.42826 | 3.88 | 0 |
30 | 930 | 6652 | 6899 | 7488 | 9552 | 10051 | 4 | 10060 | 0.00% | 4.46776 | 3.91 | 0 |
测试结果分析图
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论