¿Qué tan rápido es tu servidor?
Post date: Aug 27, 2010 3:54:58 AM
Esta es una pregunta importante, dado que en Internet, es poco probable que un usuario espere mucho por tu sitio, sobre todo si hay otros sitios más rápidos cuyos contenidos también le interesen al usuario.
Luego, justo al final del cuerpo de la marca tomamos nuevamente el tiempo y mostramos la diferencia con el tiempo inicial.
$iniciocarga = microtime(); $arreglotiempo = explode(" ", $iniciocarga); $iniciocarga = $arreglotiempo[1] + $arreglotiempo[0];
$fincarga = microtime(); $arreglotiempo = explode(" ", $fincarga); $fincarga = $arreglotiempo[1] + $arreglotiempo[0]; $tiempototal = $fincarga - $starttime; $tiempototal = round($tiempototal,10); printf ("Tiempo de carga: %f\n", $tiempototal);
En lugar de mostrar el tiempo, podemos almacenarlo para luego llevar estadísticas y eventualmente pensar en correctivos tales como cargar el código javascript en un recurso aparte, presentar menos contenidos por página o mudar el sitio a unl proveedor de hospedaje más rápido.
Cursos relacionados