Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Benchmark for cURL

By: a guest on Dec 14th, 2010  |  syntax: PHP  |  size: 1.13 KB  |  hits: 188  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. require "benchmark.php"; // http://pastebin.com/Jad5TjsQ
  3.  
  4. function CURL($url, $post = null, $retries = 2)
  5. {
  6.     global $errors;
  7.     $curl = curl_init($url);
  8.  
  9.     if (is_resource($curl) === true)
  10.     {
  11.         curl_setopt($curl, CURLOPT_FAILONERROR, true);
  12.         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  13.         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  14.         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  15.         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  16.  
  17.         if (isset($post) === true)
  18.         {
  19.             curl_setopt($curl, CURLOPT_POST, true);
  20.             curl_setopt($curl, CURLOPT_POSTFIELDS, (is_array($post) === true) ? http_build_query($post, '', '&') : $post);
  21.         }
  22.  
  23.         $result = false;
  24.  
  25.         while (($result === false) && (--$retries > 0))
  26.         {
  27.             $result = curl_exec($curl);
  28.             if($result == FALSE)
  29.                 $errors["cURL"]++;
  30.         }
  31.  
  32.         curl_close($curl);
  33.     }
  34.  
  35.     return $result;
  36. }
  37.  
  38. $result = array();
  39. $result[10000]['CURL'] = Benchmark('CURL', 'http://wizcorp.mt.dev.wizcorp.jp/', 10000);
  40. print_r($errors);