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.