Test website performance using xdebug function tracking

Source: Internet
Author: User
Tags website performance

I believe many php developers know xdebug, which is a good tool for checking errors and Performance Analysis During php development. This chapter will introduce a very good function: function tracking. It can track and record the execution time of all functions and the context of the function call based on the execution sequence of the program during actual running, including the actual parameters and return values.

To enable the xdebug function tracing function, you need to make some settings in php. ini. The settings are as follows:
Extension = php_xdebug.dll
[Xdebug]
Xdebug. auto_trace = on
Xdebug. trace_options = 1
Xdebug. trace_output_dir = "E: \ web \ server \ tmp \ xdebug \ trace"
Xdebug. trace_output_name = trace. % c

After the configuration is complete, restart Apache. Then, the execution page will generate a report file in the E: \ web \ server \ tmp \ xdebug \ trace directory.

Open the report file in the following format:
0.0348 379272-> dirname () E: \ web \ host \ mysite.com \ framework \ Controller. php: 27
0.0395 655712-> require (E: \ web \ host \ mysite.com \ framework \ smarty \ Smarty. class. php) E: \ web \ host \ mysite.com \ framework \ Controller. php: 27
0.0396 657784-> defined () E: \ web \ host \ mysite.com \ framework \ smarty \ Smarty. class. php: 37
0.0396 657824-> define () E: \ web \ host \ mysite.com \ framework \ smarty \ Smarty. class. php: 38
0.0397 657840-> defined () E: \ web \ host \ mysite.com \ framework \ smarty \ Smarty. class. php: 45
0.0398 657864-> dirname () E: \ web \ host \ mysite.com \ framework \ smarty \ Smarty. class. php: 46
0.0399 657864-> define () ........................................................................................................................ .................... ........................................................................................................................ ....................
0.0206 300960-> require_once (E: \ web \ host \ mysite.com \ app \ protected \ models \ Test. php)
0.0209 300672-> is_resource () E: \ web \ host \ mysite.com \ framework \ Model. php: 63
0.0209 300672-> Model-> _ connect () E: \ web \ host \ mysite.com \ framework \ Model. php: 63
0.0210 301776-> PDO->__ construct () E: \ web \ host \ mysite.com \ framework \ Model. php: 71
0.0253 299736-> Test-> selectData () E: \ web \ host \ mysite.com \ app \ protected \ controllers \ DefaultController. php: 25
0.0254 299896-> Model-> select () E: \ web \ host \ mysite.com \ app \ protected \ models \ Test. php: 43

From the report, you can see require (E: \ web \ host \ mysite.com \ framework \ smarty \ Smarty. class. php) took 0.0047 s, and the Test-> selectData () function took 0.0043 seconds. These two functions took much more time than other functions. Well, with these reports, we will know where we can optimize the website performance.

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.