Jmeter做性能测试,需要在jmeter设置场景和负载值,线程,用户,循环次数。设置好了保存,然后用命令行去执行性能测试,检查性能测试报告。
下面来举个简单的例子(ps:下面只是列举了使用命令自动生成的报告中包含的各种图表表示的意义):
1.打开jmeter界面新建一个线程组

2.新建三个Http请求

3.添加一个查看结果数

4.在添加一个响应断言

5.具体设置如下:
①.线程组:

设置ramp-up :ramp-up=线程数/吞吐率
设置线程数:线程数=预期qps*平均响应时间(平均响应时间单位是秒)
②.http请求:
随意找三个接口,填写域名,路径,协议,方法,请求参数,(post填写body)
③.查看结果数:
直接添加即可
④.响应断言:
设置返回码的断言,返回码为200

6.保存文件到本地,在关了jmeter
7.打开cmd进入到jmeter的bin目录运行:
jmeter -n -t C:\Users\wangtengxuan\Desktop\weather.jmx -l C:\Users\wangtengxuan\Desktop\html.csv -e -o C:\Users\wangtengxuan\Desktop\httpreports
备注:
①.-n:非GUI形式运行Jmeter
②.-t:运行的jmeter脚本路径
③.-l:运行结果保存的路径(这个文件不能是存在的,自动创建生成的)
④.-e:脚本跑完后生成性能测试的html形式的报告
⑤.-o:存放测试报告的路径(可不创建它自动会生成)
8.生成报告

打开报告整体如下图:

该报告分为两大部分Dashboard(表格)和Charts(统计图表)
(1).Dashboard中的Test and Report informations中都包含了:测试和报告信息: 测试结果文件,测试开始时间,测试结束时间,展示过滤器

(2).Dashboard中的APDEX(Application Performance Index):(应用性能指数)是一个开放的标准衡量的性能应用软件在计算。其目的是通过指定统一的方法来分析和报告测量的性能满足用户期望的程度,将测量结果转换为关于用户满意度的见解,应用程序性能满意度的标准,范围在 0-1之间,1表示达到所有用户均满意,0是没有用户满意,可以在配置文件设置。

(3).Dashboard中的Requests Summary: 请求的通过比率(OK)与失败比率(KO),百分比显示

(4). Dashboard中的Statistics:数据统计,把Summary和聚合报告结果的合并

(5).Dashboard中的Errors:错误统计,依据不同的错误类型,全部展示

(6).Dashboard中的Top 5 Errors by sampler:前五个错误信息的采集

看看Charts中都有啥?Charts有三个大模块

(1).Charts中Over Time:Response Times Over Time脚本运行时间内响应时间的曲线图

(2).Charts中Over Time:Response Time Percentiles Over Time (successful responses) 脚本运行时间里成功响应的请求,响应时间百分位

(3). Charts中Over Time:Active Threads Over Time:随时间变化的活动线程

(4).Charts中Over Time:Bytes Throughput Over Time:脚本运行时吞吐量的变化图,单位byte

(5).Charts中Over Time:Latencies Over Time脚本运行时,毫秒级的响应延时

(6).Charts中Over Time:Connect Time Over Time:脚本运行过程中平均的连接时间

(7).Charts中Throughput:Hits Per Second每秒点击次数

(8).Charts中Throughput:Codes Per Second 每秒返回的状态码的曲线

(9).Charts中Throughput:Transactions Per Second 每秒事物处理的曲线

(10).Charts中Throughput:Response Time Vs Request 响应时间和每秒请求:

(11).Charts中Throughput:Latency Vs Request 延迟vs每秒请求:

(12).Charts中Response Times:Response Time Percentiles 毫秒级别的响应时间百分位数

(13).Charts中Response Times: Response Time Overview 响应时间概述柱形图

(14).Charts中Response Times:Time Vs Threads 线程和平均响应时间变化的曲线图

(15).Charts中Response Times:Response Time Distribution 响应时间的分布图

网友评论