Maison >développement back-end >PHP7 >Comment installer et utiliser l'outil d'analyse des performances xhprof sous PHP7
Cet article vous présentera comment installer et utiliser l'outil d'analyse des performances xhprof sous PHP7. Il a une certaine valeur de référence. Les amis dans le besoin peuvent s'y référer. J'espère qu'il sera utile à tout le monde.
La version xhprof est obtenue à partir de https://github.com/longxinH/xhprof
git clone https://github.com/longxinH/xhprof
cd xhprof/extension/ phpize ./configure make make install
puis Ajoutez
extension=xhprof.so
à /etc/php.ini selon la situation et exécutez
php -m | grep xhprof
pour voir le résultat, indiquant que l'extension php est installée avec succès, puis redémarrez Apache ou php-fpm
Vous pouvez exécuter directement l'exemple dans le répertoire d'exemple dans le fichier cloné depuis github
Le résultat est le suivant
Array ( [main()] => Array ( [ct] => 1 [wt] => 9 ) ) --------------- Assuming you have set up the http based UI for XHProf at some address, you can view run at http://<xhprof-ui-address>/index.php?run=592567308784c&source=xhprof_foo ---------------
Ensuite, copiez le ? run=592567308784c&source=xhprof_foo après index.php
Visitez
xhprof_html/index.php?run=592567308784c&source=xhprof_foo
pour voir le résultat
Cliquez sur Afficher le graphique de calligraphie complet au milieu pour voir l'image de l'analyse des performances
failed to execute cmd:" dot -Tpng". stderr:sh: dot:command not found。rrree
Par exemple, si vous souhaitez tester votre propre projet, comme l'analyse des performances d'un framework.
Copiez les deux fichiers
xhprof_lib.php et xhprof_runs.php dans le même répertoire que le fichier d'entrée, puis ajoutez
//解决方案 yum install graphvizAjouter
// start profiling xhprof_enable();jusqu'à la position finale pour obtenir l'URL indiquée ci-dessus, puis visitez à nouveau
// stop profiler $xhprof_data = xhprof_disable(); // display raw xhprof data for the profiler run print_r($xhprof_data); include_once "xhprof_lib.php"; include_once "xhprof_runs.php"; // save raw data for this profiler run using default // implementation of iXHProfRuns. $xhprof_runs = new XHProfRuns_Default(); // save the run under a namespace "xhprof_foo" $run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo"); echo "---------------\n". "Assuming you have set up the http based UI for \n". "XHProf at some address, you can view run at \n". "http://<xhprof-ui-address>/index.php?run=$run_id&source=xhprof_foo\n". "---------------\n";pour obtenir la page affichée ci-dessous
Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!