Couldn't wait
Did a small test again with this code:
Code: Select all
<?php
$start=microtime(true);
if(false!==stream_resolve_include_path('/volume1/web/secure/pass2php/pirinkom.php')) $result='OK';else $result='NOK';
$total=microtime(true)-$start;
echo number_format(($total*1000),5) .' absolute stream_resolve_include_path '.$result.'<br>';
$start=microtime(true);
if(false!==stream_resolve_include_path('pass2php/pirkeuken.php')) $result='OK';else $result='NOK';
$total=microtime(true)-$start;
echo number_format(($total*1000),5) .' relative stream_resolve_include_path '.$result.'<br>';
$start=microtime(true);
if(file_exists('/volume1/web/secure/pass2php/pirliving.php')) $result='OK';else $result='NOK';
$total=microtime(true)-$start;
echo number_format(($total*1000),5) .' absolute file_exists '.$result.'<br>';
$start=microtime(true);
if(file_exists('pass2php/pirgarage.php')) $result='OK';else $result='NOK';
$total=microtime(true)-$start;
echo number_format(($total*1000),5) .' relative file_exists '.$result.'<br>';
$start=microtime(true);
if(is_file('/volume1/web/secure/pass2php/raamtobi.php')) $result='OK';else $result='NOK';
$total=microtime(true)-$start;
echo number_format(($total*1000),5) .' absolute is_file '.$result.'<br>';
$start=microtime(true);
if(is_file('pass2php/pirhall.php')) $result='OK';else $result='NOK';
$total=microtime(true)-$start;
echo number_format(($total*1000),5) .' relative is_file '.$result.'<br>';
Output should be this:
0.03386 absolute stream_resolve_include_path OK
0.03219 relative stream_resolve_include_path OK
0.17405 absolute file_exists OK
0.17095 relative file_exists OK
0.35405 absolute is_file OK
0.32997 relative is_file OK
I used 6 different existing files to avoid file caching OS things.
Personnally I find it strange that relative files are in each function a little bit faster but that's no noticable number.
The difference between the functions... Clearly in my case the stream_resolve... is the fastest.
Test in on your system, check if each line ends with OK, telling you the function works and the file is found. Use the fastest of them.
Wichever you choose, this will not be the biggest change, we're talking about 0,3 milliseconds here.