Your privacy is important to us! Our website uses cookies, for which we need your consent. Please review here our personal data handling and cookie policy.
|
||||||||||
|
In order to profile PHP scripts, you must instruct the php profiler to generate a trace file. The trace file contains the tree of all the calls your program executes, and can then be further processed to show you a visual representation for your program's execution time or memory usage.
The WEB3TRACER_OUTPUT_PROCESSED output mode returns the processed call tree in a native PHP array variable, similar but not identical to XHProf PHP profiler's; for the output format reference view read Processed output format
To generate the trace data, you must use in your code a pair of functions: web3tracer_enable and web3tracer_disable; the first one starts, the other stops, the PHP profiler. This is very similar to the XHProf approach. These are the only 2 functions the module exposes to PHP. To write the processed data another writer function is needed, by first including the relevant writer file. So, to profile a piece of code, all that's needed is in the form:
A more elaborate example PHP file, ready for both devel and production sampling would look like:
The above file is also included in the samples folder of the download.
Important notes:
Since ellaborate computations are made for recursion handling, we enforce that the web3tracer_enable and web3tracer_disable must be called in the same function, or the global code. Failing to do so will result in a WEB3TRACER_ERROR_NESTING result on web3tracer_disable; see the section on constants for more details. |