![]() |
|||||
XDEBUG EXTENSION FOR PHP | DOCUMENTATION - PROFILER - XDEBUG 2 home | updates | installation | documentation | screenshots | license | support
> General: Configurating Settings,
Functions
> Profiling: Xdebug 1, Xdebug 2 > Debugger: Usage, GDB Protocol, DBGp Protocol > FAQ: Frequently Asked Questions > Download Documentation INTRODUCTION 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, KDE) to analyse your profiling data. In case you can not use KDE (or do not want to use KDE) the kcachegrind package also comes with a perl script "ct_annotate" which produces ASCII output from the profiler trace files. STARTING THE PROFILERProfiling 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 current working directory. Make sure you have enough space in your dump directory 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. ANALYSING PROFILESAfter a profile information file has been generated you can open it with KCacheGrind: Once the file is opened you have plenty of information available in the
different panes of KCacheGrind. On the left side you find the "Flat Profile"
pane showing all functions in your script sorted by time spend in this function,
and all its children.
The pane on the left exist of an upper and lower pane. The upper one
shows information about which functions called the current selected function
("eztemplatedesignresource->executecompiledtemplate in the screenshot).
The "Cost" column in the upper pane shows the time spend in the current selected function while being called from the function in the list. The numbers in the Cost column added up will always be 100%. The "Cost" column in the lower pane shows the time spend while calling the function from the list. While adding the numbers in this list up, you will most likely never reach 100% as the selected function itself will also takes time to execute. The "All Callers" and "All Calls" tabs show not only the direct call from
more will follow soon |
|
||||
This site and all of its contents are
Copyright © 2002, 2003, 2004 by Derick Rethans.
All rights reserved. |