1<?php 2/** 3 * This code can help to 'benchmark' your sessions engine besides checking a site status (up/down) 4 */ 5$url = 'http://dalmp.localbox.org/sessions.php'; 6 7require_once '../mplt.php'; 8$timer = new mplt(); 9 10function checkSite($url,$page=null) 11{ 12 $cookie = '/tmp/cookie.txt'; 13 $agent = '-( DALMP )-'; 14 $ch=curl_init(); 15 curl_setopt ($ch, CURLOPT_URL,$url ); 16 curl_setopt ($ch, CURLOPT_USERAGENT, $agent); 17 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 18 curl_setopt ($ch, CURLOPT_VERBOSE,false); 19 curl_setopt ($ch, CURLOPT_TIMEOUT, 5); 20 curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie); 21 curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); 22 $page=curl_exec($ch); 23 $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 24 curl_close($ch); 25 if (isset($page)) { 26 return $page; 27 } else { 28 return ($httpcode>=200 && $httpcode<300) ? true :false; 29 } 30} 31 32/** 33 * benchmark for sessions 34 */ 35for ($i=0; $i < 100; $i++) { 36 for ($j=0; $j < 30; $j++) { 37 echo checkSite($url,1).PHP_EOL; 38 } 39 @unlink('/tmp/cookie.txt'); 40} 41 42# ----------------------------------------------------------------------------------------------------------------- 43echo PHP_EOL,str_repeat('-', 80),PHP_EOL,'Time: ',$timer->getPageLoadTime(),' - Memory: ',$timer->getMemoryUsage(1),PHP_EOL,str_repeat('-', 80),PHP_EOL; 44