PHP接口并发测试的方法
<pre>
header(‘Content-type:text/html; Charset=utf-8‘);
$uri = "输入你的url";
$data = array(
‘test‘=>1
);
$ch = curl_init();
// print_r($ch);
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$return = curl_exec($ch);
curl_close($ch);
</pre>
然后用ab小工具测试
键入命令:
ab -n 800 -c 800 http://192.168.0.10/
(-n发出800个请求,-c模拟800并发,相当800人同时访问,后面是测试url 一般用本地测试就行了)
原文地址:https://www.cnblogs.com/newmiracle/p/11875287.html
时间: 2024-12-19 00:31:25