# PHP - Slow filemtime results?



## Mayhem30 (Aug 2, 2013)

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


```
<?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 :


```
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?


----------



## SirDice (Aug 2, 2013)

Mayhem30 said:
			
		

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


Which is 9.0599060058594*10^-6 or 0.00000905. 

https://en.wikipedia.org/wiki/Scientific_notation#E_notation


----------

