首页 > 其他分享 >ab post 测试性能

ab post 测试性能

时间:2023-01-06 15:13:59浏览次数:24  
标签:index www ab -- abTest 测试 post

https://blog.csdn.net/qq_27878777/article/details/125780158

一. 请求
post参数 postdata.txt

name=chang&password=11111ok

PS: 记住请求链接, 参数 用双引号, 否则接收不到参数

ab -n 1 -c 1 -p D:\phpstudy_pro\WWW\postdata.txt -T application/x-www-form-urlencoded -H "token:eyJhbGciOiJIU" "http://www.test.com/index/index/abTest"
1
测试报告导出到html ,请加 -w 格式化网页

ab -w -n 1 -c 1 -p D:\phpstudy_pro\WWW\postdata.txt -T application/x-www-form-urlencoded -H "token:eyJhbGciOiJIU" "http://www.test.com/index/index/abTest" >> >>D:\miss.html
1
简单使用
简单使用说明

最基本的关心两个选项 -c -n 例: ab -n 1000 -c 100 http://www.baidu.com/
-n 1000 即: 共发送1000个请求
-c 100 即:每次并发100个

二. 接收参数
/**
* ab 压力测试带post,header头 参数
*/
public function abTest(Request $request)
{
$fileName = __DIR__ .'/cert/abtest.txt';
$tmpArr = array();

$name = $request->post('name');
$password = $request->post('password');
$token = $request->header('token');


if($name && $password){
$tmpArr = $request->pathinfo();

$jsonStr = json_encode($tmpArr);
$newLog ='log_time:'.date('Y-m-d H:i:s ').$jsonStr." {$name} -- {$password} -- {$token} ";
file_put_contents($fileName,$newLog.PHP_EOL,FILE_APPEND);
return 'ab测试';
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
三. 请求记录
abtest.txt

log_time:2022-07-14 10:59:15 "index\/abTest" chang -- 11111ok -- token111
log_time:2022-07-14 10:59:58 "index\/abTest" chang -- 11111ok -- eyJhbGciOiJIU
1
2
这是 ApacheBench,版本 2.3 <$Revision: 1843412 $>
版权所有 1996 Adam Twiss,Zeus Technology Ltd,http ://www.zeustech.net/
授权给 Apache 软件基金会,http://www.apache.org/
..完毕
服务器软件: 阿帕奇/2.4.39
服务器主机名: www.test.com
服务器端口: 80
文档路径: /index/index/abTest
文件长度: 33197 字节
并发级别: 1
测试所需时间: 0.067 秒
完成请求: 1
失败的请求: 0
转让总额: 33420 字节
发送的整体: 221
传输的 HTML: 33197 字节
每秒请求数: 14.83
传输率: 收到 484.11 kb/s
3.20 kb/s 发送
总计 487.31 kb/s
连接时间(毫秒)
分钟 平均 最大限度
连接: 1 1 1
加工: 66 66 66
全部的: 67 67 67
————————————————
版权声明:本文为CSDN博主「qq_27878777」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_27878777/article/details/125780158

标签:index,www,ab,--,abTest,测试,post
From: https://www.cnblogs.com/jzxy/p/17030523.html

相关文章