$query_arr = array();
for ($k = 0;$k<5;$k++){//请问5代表的是什么?
$query_arr[] = 'http://www.segmentfault.com/json';
}
for ($i = 0;$i<70;$i++){//请问70代表的是什么?
$ch = curl_multi_init();
$count = count($query_arr);
$ch_arr = array();
for ($j = 0; $j < $count; $j++) {
$query_string = $query_arr[$j];
$ch_arr[$j] = curl_init($query_string);
curl_setopt($ch_arr[$j], CURLOPT_RETURNTRANSFER, true);
curl_multi_add_handle($ch, $ch_arr[$j]);
}
$running = null;
do {
curl_multi_exec($ch, $running);
} while ($running > 0);
for ($l = 0; $l < $count; $l++) {
$results[$l] = curl_multi_getcontent($ch_arr[$l]);
curl_multi_remove_handle($ch, $ch_arr[$l]);
}
curl_multi_close($ch);
}
What do the 5 and 70 in the code represent?
Five URLs were created (ps: these 5 URLs are the same) and executed 70 times in total, which means a total of 350 requests can be understood as 5 concurrent executions 350 times
Similar to ab's ab -c 5 -n 350 http ://www.segmentfault.com/json
However, curl_multi_init is a method of IO multiplexing. There is a certain difference between it and the real stress test interface. You can try ab siege
or use pthreads to execute scripts for concurrent testing
That’s 5 concurrencies, looping 70 times. . . Nothing special