PHP - Slow filemtime results?

I'm currently using PHP 5.3.27 and FreeBSD 8.3-RELEASE-p3 and seeing some really slow filemtime results.

PHP:
<?php
$file = "layout.css";
$file_size = filesize($file);

//get the filemtime 20 times
$start_time = microtime(true);
for($i=0;$i<20;$i++){
    $set_time = filemtime($file);
}
$end_time = microtime(true);

$time_for_filemtime = ($end_time-$start_time);

//get the time for file_get_contents 20 times
$start_time = microtime(true);
$file = "layout.css";
for($i=0;$i<20;$i++){
    $set_time = file_get_contents($file);
}
$end_time = microtime(true);

$time_for_file_get_contents = ($end_time-$start_time);

echo "<p>Working on a file that is $file_size B long</p>
<p>filemtime: $time_for_filemtime vs file_get_contents: $time_for_file_get_contents";
?>

Output :

Code:
Working on a file that is 8224 B long

filemtime: 9.0599060058594E-6 vs file_get_contents: 0.00040793418884277

On stackoverflow, someone did a 1,000,000 loop test and their filemtime results were : 0.36287999153137.

I'm just doing 20 loops and mine is showing : 9.0599060058594E-6

Any idea why my results are so slow?
 
Back
Top