Tempo de execução do script em PHP
Publicado por Angelito Monteiro Goulart (última atualização em 06/12/2011)
[ Hits: 15.466 ]
Homepage: http://angelitomg.com
Script que calcula o tempo que a página levou para ser processada.
Deve-se incluir o arquivo exec_time.php no início do script, chamar a função startExec() logo após e no final do script deve-se chamar a função endExec(), responsável por finalizar a medição e exibir o resultado na tela.
<?php
/*
*
* @file: exec_time.php
*
* @author: Angelito M. Goulart
*
* @date: 22/11/2011
*
* @description: calculates the time of execution of a script
*
* @use: include this file in the top of the script, call function startExec() and
* the end of script call the function endExec().
*
* Function endExec print results in the screen.
*
*/
global $time;
/* Get current time */
function getTime(){
$microtime = explode(" ", microtime());
$time = $microtime[0] + $microtime[1];
return $time;
}
/* Calculate start time */
function startExec(){
global $time;
$time = getTime();
}
/*
* Calculate end time of the script,
* execution time and print
* result in the screen
*/
function endExec(){
global $time;
$finalTime = getTime();
$execTime = $finalTime - $time;
echo 'Execution time: ' . number_format($execTime, 6) . ' ms';
}
?>
Classe para gerar calendário em PHP
Upload de fotos com banco de dados
XFCE - quase um Gnome ou Plasma mas muito mais leve
LXQT - funcional para máquinas pererecas e usuários menos exigentes
Instalação do K3s Single-Node com Rancher no Ubuntu 24.04
Usei o NotebookLM para Auditar Logs do Linux
Cinnamon seria a aposta acertada frente às outras interfaces gráficas mais populares?
Samba 4 AD-DC 2026: Como instalar e configurar um Active Directory (via APT-GET)
[Resolvido] Sumiço de redes e micro quedas no iwd/iwgtk (Realtek rtw88)
Como Configurar DNS Reverso (PTR) em Ambientes Linux e Microsoft
Preparando o Ambiente para Administrar o Samba 4 a partir do Windows com RSAT
Midia de instalação LM-21.3 não inicializa (7)
A diferença entre a fala de um Samuel e a fala de alguém que conhece o... (8)









