Skip to content

Instantly share code, notes, and snippets.

@kadai
Created May 8, 2018 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kadai/c4d7193369865879d67b9b7efbef75d9 to your computer and use it in GitHub Desktop.
Save kadai/c4d7193369865879d67b9b7efbef75d9 to your computer and use it in GitHub Desktop.
Función para conocer el desempeño de WordPress
<?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