Tempo de execução do script em PHP
Publicado por Angelito Monteiro Goulart (última atualização em 06/12/2011)
[ Hits: 14.655 ]
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'; } ?>
Formatando data de yyyy/mm/dd para dd/mm/yyyy
Atenção a quem posta conteúdo de dicas, scripts e tal (6)
Como Configurar um Túnel SSH Reverso para Acessar Sua Máquina Local a Partir de uma Máquina Remota
Configuração para desligamento automatizado de Computadores em um Ambiente Comercial
O mínimo que você precisa saber sobre o terminal (parte 2)
O mínimo que você precisa saber sobre o terminal (parte 1)
Como iniciar uma máquina virtual do VirtualBox automaticamente no boot do LUbuntu 18 LTS
Mudar o gerenciador de login (GDM para SDDM e vice-versa) - parte 2
Como deixar as abas do Firefox mais fininhas
Mudar o gerenciador de login (GDM para SDDM)
"Tentando" fazer com que programas rodem no Wayland e no X11
Como posso localizar o arquivo HTML da página inicial do GLPI dentro d... (2)
O que você está ouvindo agora? [2] (164)
Como baixar os drivers de áudio no linux mint? (6)
Erro ao iniciar Ubuntu 24.04.1 LTS - Management Owner Key - MoK (6)
[Python] Automação de scan de vulnerabilidades
[Python] Script para analise de superficie de ataque
[Shell Script] Novo script para redimensionar, rotacionar, converter e espelhar arquivos de imagem
[Shell Script] Iniciador de DOOM (DSDA-DOOM, Doom Retro ou Woof!)
[Shell Script] Script para adicionar bordas às imagens de uma pasta