Xhprof Installation Notes (PHP performance monitoring)

Source: Internet
Author: User

Xhprof is an open source PHP performance monitoring tool for Facebook that takes up little resources and can even be deployed in a production environment. It can be used in conjunction with Graphviz, can be visualized in the form of pictures to show Code execution time wget http://pecl.php.net/get/xhprof-0.9.2.tgzTar zxvf xhprof-0.9.2.TGZCD xhprof-0.9.2/extension//usr/bin/phpize./configure--with-php-config=/usr/local/php/bin/php-Configmake&&Make Install#edit php.ini:[Xhprof]extension= Xhprof.soxhprof. output_dir=/tmp Restart service PHP-fpm Restart#under test<?PHPfunctionMy_dump ($str) { Print $str;}        Xhprof_enable (); //Start ProfilingMy_dump (' funsion Wu ');//Run Program$xhprof _data= Xhprof_disable ();//Stop ProfilerPrint_r($xhprof _data);//Display Raw xhprof data for the profiler run?>#Finally, the array is returned, which means the installation is ready. What are the specific values? Forget about it, because there is a configuration of the UI below. It will be intuitive! Yum-y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel vixie-cron crontabs readline-devel tk-devel te Lnet zlib zlib-devel libjpeg freetype freetype-devel lcms lcms-devel tkinter python-tools libjpeg-Develyum-y install liberation-sans-fonts.noarch wget http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.24.0.tar.gzTar zxf Graphviz-2.24.0.tar.GZCD Graphviz-2.24.0./Configuremake&&when the make install is complete, it generates/usr/local/bin/dot file, you should make sure that the path is in the PATH environment variable so that xhprof can find it. Configure an Access site for Xhprof (virtual host) For example, make a virtual domain name Xhprof.Dev binds to Xhprof's site root directory/usr/local/xhprof-0.9.2/xhprof_html#Find the code you want to analyze and add it at the beginning of the codeXhprof_enable ();//Start Profiling#add at end of code$xhprof _data= Xhprof_disable ();//Stop Profiler, display raw xhprof data for the profiler runinclude_once("/usr/local/xhprof-0.9.2/xhprof_lib/utils/xhprof_lib.php");include_once("/usr/local/xhprof-0.9.2/xhprof_lib/utils/xhprof_runs.php");$xhprof _runs=NewXhprofruns_default ();//Save the run under a namespace "Xhprof_foo".//**note**://By default Save_run () would automatically generate a unique Run ID for you. [You can override this behavior by passing//a run ID (optional arg) to the Save_run () method instead.]$run _id=$xhprof _runs->save_run ($xhprof _data, "Xhprof_foo");Echo"\ r \ n------------------\ r \ n". Assuming you has set up the HTTP based UI for \ r \ n "." Xhprof at some address, you can view run at \ r \ n "." http://xhprof.dev/index.php?run=$run _id&source=xhprof_foo "." \ r \------------------\ r \ n "and then go to the URL of the program output (e.g. HTTP://Xhprof.dev/index.php?run=52c0ea0bef834&source=xhprof_foo), to viewHere are some parameter descriptions inclusive Timeincludes all execution times for child functions. Exclusive Time/self Timethe time it takes the function to execute itself, not including the subtree execution time. Wall Timespent the time or the wall clock time. CPU TimeUser Time consumption +The time the kernel consumes inclusive CPU, including the Cpuexclusive CPU function that is occupied by the sub-function, is consumed by the CPU Click [View full CallGraph] Can be viewed in the form of graphic, very convenient to note: the need to use CType this extension, callgraph image generation relies on some PHP system-level functions, so it is best to remove PHPFunctions in. ini are disabled

Xhprof Installation Notes (PHP performance monitoring)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.