Para saber el tiempo que tarda en ejecutar una función / script / tarea en PHP y ver dónde se produce el mayor gasto de tiempo, se puede usar:
<!-- put this at the top of the page -->
<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
;?>
<!-- put other code and html in here -->
<!-- put this code at the bottom of the page -->
<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo "This page was created in ".$totaltime." seconds";
;?>
Sacado de http://www.developerfusion.com/code/2058/determine-execution-time-in-php/
No hay comentarios:
Publicar un comentario