function perfmon_test_server_configuration in Performance monitor 7
Same name and namespace in other branches
- 8 perfmon.module \perfmon_test_server_configuration()
Test configuration.
1 string reference to 'perfmon_test_server_configuration'
- _perfmon_performance_tests in ./
perfmon.inc - Core Perfmon checks.
File
- ./
perfmon.inc, line 125 - Stand-alone perfmon test system.
Code
function perfmon_test_server_configuration() {
global $_SESSION;
global $base_url;
$domain = $_SERVER['SERVER_NAME'];
$port = $_SERVER['SERVER_PORT'];
$request_uri = '/perfmon.test.php';
$url = $base_url . $request_uri;
$execcount = 5;
$exectime = 0;
$count = 10;
$curl_arr = array();
$master = curl_multi_init();
$cookiestr = "";
foreach ($_COOKIE as $key => $value) {
$cookiestr = $cookiestr . $key . "=" . $value . "; ";
}
for ($k = 0; $k < $execcount; $k++) {
for ($i = 0; $i < $count; $i++) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt($ch, CURLOPT_COOKIE, $cookiestr);
curl_setopt($ch, CURLOPT_PORT, $port);
curl_setopt($ch, CURLOPT_MAXREDIRS, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curl_arr[$i] = $ch;
curl_multi_add_handle($master, $curl_arr[$i]);
}
do {
curl_multi_exec($master, $running);
} while ($running > 0);
for ($i = 0; $i < $count; $i++) {
$info = curl_getinfo($curl_arr[$i]);
$exectime += $info['starttransfer_time'] - $info['pretransfer_time'];
curl_multi_remove_handle($master, $curl_arr[$i]);
curl_close($curl_arr[$i]);
}
sleep(2);
}
return array(
'result' => round(1 / ($exectime / $execcount / $count), 0),
'value' => '0',
);
}