1.下载xdebug
1 | phpinfo(); |
结果直接从网页上复制到http://xdebug.org/find-binary.php 页面中,获得下载提示及安装说明
- $storageDir - path to a writeable directory where webgrind will store processed cachegrind files
- $profilerDir - If Xdebug is not installed, this variable defines a directory searched for cachegrind files. If Xdebug is installed, webgrind will look for cachegrind files defined by the xdebug.profiler_output_dir setting. The default is /tmp.
Profiling is enabled by setting the xdebug.profiler_enable setting to 1 in php.ini. This instructs Xdebug to start writing profiling information into the dump directory configured with the xdebug.profiler_output_dir directive. The name of the generated file always starts with “cachegrind.out.” and ends with either the PID (process ID) of the PHP (or Apache) process or the crc32 hash of the directory containing the initially debugged script. Make sure you have enough space in your xdebug.profiler_output_dir as the amount of information generated by the profiler can be enormous for complex scripts, for example up to 500MB for a complex application like eZ Publish.
Xdebug’s Profiler is a powerful tool that gives you the ability to analyze your PHP code and determine bottlenecks or generally see which parts of your code are slow and could use a speed boost. The profiler in Xdebug 2 outputs profiling information in the form of a cachegrind compatible file. This allows you to use the excellent KCacheGrind tool (Linux/Windows, KDE) to analyse your profiling data. If you are on Linux you can install KCacheGrind with your favourite package manager; if you are on Windows you can get precompiled binaries of KCacheGrind at SourceForge.
Users of Windows can also use WinCacheGrind, the functionality is different from KCacheGrind so the section that documents the use of KCacheGrind on this page doesn’t apply to this program. There is also an alternative profile information presentation tool called xdebugtoolkit and a web based front-end called Webgrind.
- Download webgrind.
- Extract webgrind to a folder accessible to the webserver.
- Start using webgrind with your browser of choice by navigating to the URL of your webgrind install, e.g. http://localhost/webgrind.