File: 1.04.2a/server/test/curl.sh (View as Code)

1: #!/usr/bin/php -q 2: 3: require("../base/timer.inc.php"); 4: require("../base/tests.inc.php"); 5: 6: if ($argc!=2) 7: { 8: echo "Usage: curl.sh url\n"; 9: exit(); 10: } 11: 12: $timer=new TFNTimer(); 13: 14: $cmd="curl -o \"curl.txt\" -s -S --insecure --connect-timeout 10 "; 15: $cmd.="-w 'CURL Time: %{time_total} ' ".$argv[1]; 16: echo $cmd."\n\n"; 17: $timer->Start(); 18: passthru($cmd); 19: $curl=$timer->Stop(); 20: echo "\n"; 21: echo "FN Timer : ".$curl." (".($curl*1000)." ms)\n\n"; 22: 23: $timer->Start(); 24: $wtime=DoTest("wtime",$argv[1]); 25: $wtimer=$timer->Stop(); 26: echo "WTime : ".$wtime."\n"; 27: echo "Timer : ".$wtimer."\n"; 28: echo "\n"; 29: 30: 31: $timer->Start(); 32: $ch=curl_init(); 33: curl_setopt($ch,CURLOPT_URL,$argv[1]); 34: curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 35: curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0); 36: curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0); 37: if (!$output=curl_exec($ch)) 38: { 39: echo "CURL Error\n"; 40: $size=0; 41: } 42: else $size=curl_getinfo($ch,CURLINFO_SIZE_DOWNLOAD); 43: curl_close($ch); 44: $curltime=$timer->Stop(); 45: 46: echo "PHP CURL : ".$curltime."\n"; 47: echo "Size : ".$size."\n"; 48: echo "\n"; 49: 50: $timer->Start(); 51: $fp=fopen($argv[1],"r") 52: or die("fopen failed"); 53: $fopen=$timer->Stop(); 54: while (!feof($fp)) 55: { 56: $s=fgets($fp,1024); 57: } 58: $fgets=$timer->Stop(); 59: fclose($fp); 60: 61: echo "fopen : ".$fopen."\n"; 62: echo "fopen Tot : ".$fgets."\n"; 63: echo "\n"; 64: 65: ?> 66: