What is the best practice for benchmarking in PHP?
This is what I want to do:
I have setup a Saas product and I want to issue with cURL multiple parallel http requests towards that URL.
Up to now I have built a cURL function that looks like so:
function getCurl($strUrl, $arrParams, $intTimeout = null, $blnReturn = true, $blnVerbose = false, $blnHeader = false){
if(isset($strUrl)){
if(is_array($arrParams)){
$strUrl.= '?';
foreach($arrParams as $key=>$value){
$strUrl.=$key.'='.$value;
$strUrl.='&';
}
$strUrl = substr_replace($strUrl,'',strlen($strUrl)-1,1);
try{
$curl = curl_init($strUrl);
}catch(Exception $e){
throw new Exception('Invalid URL');
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, $blnReturn);
curl_setopt($curl, CURLOPT_VERBOSE, $blnVerbose);
if($intTimeout){
curl_setopt($curl, CURLOPT_TIMEOUT, $intTimeout);
}
curl_setopt($curl, CURLOPT_HEADER, $blnHeader);
if(strpos($strUrl, 'https') !== FALSE){
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
}
$data = curl_exec($curl);
if($blnReturn){
return $data;
}
curl_close($curl);
return true;
}
}
return false;
}
Any idea how to improve this to allow parallel reuests?
Any other way to do this in respect to best practice?
Thank you!