Source string: http://www.controlstyle.ru/dir1/dir2/di3/file.htm?param1=value1¶m2=value2¶m3=value3
Preg_match time, s*106: 61.03515625
Parse_url time, s*106: 15.974044799805
Source code:
<?php
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$source = 'http://www.controlstyle.ru/dir1/dir2/di3/file.htm?param1=value1¶m2=value2¶m3=value3';
$mt_preg = getmicrotime();
$result = array();
preg_match('#^http://(.*)/.*$#Uis', $source, $result);
$result = $result[1];
$mt_preg = (getmicrotime()-$mt_preg) * 1000000;
$mt_pars = getmicrotime();
$result = parse_url($source);
$result = $result['host'];
$mt_pars = (getmicrotime()-$mt_pars) * 1000000;
echo '<b>Source string:</b> ' . $source . "<br /><br />";
echo '<b>Preg_match time, s*10<sup>6</sup>:</b> ' . $mt_preg . "<br />";
echo '<b>Parse_url time, s*10<sup>6</sup>:</b> ' . $mt_pars . '<br /><br /><b>Source code:</b><br /><br />';
echo highlight_file('index.php', true);
?>