
Benchmark for file_get_contents
By: a guest on
Dec 14th, 2010 | syntax:
PHP | size: 0.90 KB | hits: 87 | expires: Never
<?php
require "benchmark.php"; // http://pastebin.com/Jad5TjsQ
function FGC($url, $post = null, $retries = 3)
{
global $errors;
$http = array
(
'method' => 'GET',
);
if (isset($post) === true)
{
$http['method'] = 'POST';
$http['header'] = 'Content-Type: application/x-www-form-urlencoded';
$http['content'] = (is_array($post) === true) ? http_build_query($post, '', '&') : $post;
}
$result = false;
while (($result === false) && (--$retries > 0))
{
try
{
$result = file_get_contents($url, false, stream_context_create(array('http' => $http)));
}
catch(Exception $e)
{
$errors["FGC"]++;
}
}
return $result;
}
$result = array();
$result[10000]['FGC'] = Benchmark('FGC', 'http://wizcorp.mt.dev.wizcorp.jp/', 10000);
print_r($errors);