This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Benchmark for file_get_contents

By: a guest on Dec 14th, 2010  |  syntax: PHP  |  size: 0.90 KB  |  views: 107  |  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 FGC($url, $post = null, $retries = 3)
  5. {
  6.     global $errors;
  7.     $http = array
  8.     (
  9.         'method' => 'GET',
  10.     );
  11.  
  12.     if (isset($post) === true)
  13.     {
  14.         $http['method'] = 'POST';
  15.         $http['header'] = 'Content-Type: application/x-www-form-urlencoded';
  16.         $http['content'] = (is_array($post) === true) ? http_build_query($post, '', '&') : $post;
  17.     }
  18.  
  19.     $result = false;
  20.  
  21.     while (($result === false) && (--$retries > 0))
  22.     {
  23.         try
  24.         {
  25.             $result = file_get_contents($url, false, stream_context_create(array('http' => $http)));
  26.         }
  27.         catch(Exception $e)
  28.         {
  29.             $errors["FGC"]++;
  30.         }
  31.     }
  32.  
  33.     return $result;
  34. }
  35.  
  36. $result = array();
  37. $result[10000]['FGC'] = Benchmark('FGC', 'http://wizcorp.mt.dev.wizcorp.jp/', 10000);
  38. print_r($errors);
clone this paste RAW Paste Data