The following PHP profiler example script recurses between functions a(), b() and c(), having a usleep in each as payload (the script is also included in the examples folder):
All times are expressed in nanoseconds; this is because KCachegrind doesn't play with float values, and there are many times a call can take less than one microsecond. Kudos to the XHProf team for the excellent time measuring functions.
The date() function which generates the trace filename takes 5 miliseconds! Yeap, for anyone who didn't know, date() is a huge time hog!
The b => b recursion has been decoupled into <CYCLE b> =[12x]> b, keeping the times spent in each call (3ms) intact
The a => c => a cycle has been decoupled (c => a call moved upwards) into <CYCLE a> =[5x]> a =[4x]> c, keeping the right times, so c is correctly credited with 16ms
Although the c => a => c sequence of calls is also a cycle, decoupling the c calls (a => c) is not necessary, as the c => a link has already been decoupled by the PHP profler (see above point). Therefore, no <CYCLE c> node has been generated, keeping maximum readability of the call graph.
Along with the very small overhead, the correct handling of recursion is one of the strong points of web3tracer PHP profiler.
You can download the trace file here and play with it in KCachegrind. (You may have to copy this and paste in a local file if your browser opens this as text). Be sure to check the next examples for a real world example of using the PHP profiler as well as another synthetic example of PHP memory usage profiling.
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.