Created
May 8, 2018 03:32
-
-
Save kadai/c4d7193369865879d67b9b7efbef75d9 to your computer and use it in GitHub Desktop.
Función para conocer el desempeño de WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('wp_footer', dtorrer_diagnostico); | |
function dtorrer_diagnostico(){ | |
$datos = array(); | |
$datos[] = 'Fecha: ' . date('Y-m-d H:i:s'); | |
$datos[] = 'Tiempo: ' . timer_stop(0, 2) . ' segundos.'; | |
if (function_exists('memory_get_usage')) { | |
$unidades = array('b','kb','mb','gb','tb','pb'); | |
$memoria = memory_get_usage(true); | |
$i = floor(log($memoria,1024)); | |
$valor = @round($memoria/pow(1024,$i),2) . ' ' . $unidades[$i]; | |
$datos[] = 'Memoria: ' . $valor; | |
} | |
$datos[] = 'Consultas: ' . get_num_queries(); | |
if(current_user_can('update_core')){ | |
echo '<p>' . implode('<br>', $datos) . '</p>'; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment