< ?php
// Benchamarking the script
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$time = getmicrotime();
function compress_output($output)
{
// We can perform additional manipulation on $output here, such
// as stripping whitespace, etc.
return gzencode(trim($output));
}
// Check if the browser supports gzip encoding, HTTP_ACCEPT_ENCODING
if (strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip')) {
// Start output buffering, and register compress_output() (see
// below)
ob_start("compress_output");
// Tell the browser the content is compressed with gzip
header("Content-Encoding: gzip");
}
for($i=0;$i<50000;$i++)
print $i;
echo "Time elapsed: ",getmicrotime() - $time, " seconds";
?>
< ?php
// Benchamarking the script
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$time = getmicrotime();
for($i=0;$i<50000;$i++)
print $i;
echo "Time elapsed: ",getmicrotime() - $time, " seconds";
?>