NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Remote profiling


Joined: 01 Oct 2010
Posts: 7
Reply with quote
Hi here,

I am trying to figure out how I can remotely start the profiler. I am looking for something like DebugBreak(); but for the profiler.

Here is my setup:

(1) I have some PHP script that generates some webpage (let's call it A.php)
(2) The A.php script does send a query, to a web service endpoint (let's call it B.php) using a curl Query
(3) I want to start the profiler for the B.php script, when the A.php page get loaded.

When performing a normal debugging session, I can easily enable this behavior by using the DebugBreak() dbg API.

However, I can't figure out how I can enable the profiler remotely (I have PhpED Professional 6.1).

I really have to be able to do this, because I need to profile the script, using the query sent by the A.php script.


Thanks for your help!

Take care,

Fred
View user's profileFind all posts by fgiassonSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7857
Reply with quote
it's easy. Using cURL api supply DBGSESSID variable with your request to b.php. This variable can be sent in form of GET value, POSTed value, or COOKIE. An appropriate syntax for this variable is below:
DBGSESSID=1@myclientIPaddress:7869;d=0,p=1
where
d=0 means don't debug code, p=1 means profile code
myclientIPaddress means your client IP address - the address of the machine where you run PhpED.
If there is a router between your client machine and the host servicing b.php (f.e. their networks are different), you have to either a) specify IP address of this router and turn NAT forwarding on it to forward incoming connections on 7869 port to your real client machine or b) specify "localhost" and use SSH tunnel.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 01 Oct 2010
Posts: 7
Reply with quote
Hi Dmitri!

Great! Let me test this once over the weekend and I will come back here if I still have issues with that.



Thanks,

Take care,

Fred
View user's profileFind all posts by fgiassonSend private message


Joined: 01 Oct 2010
Posts: 7
Reply with quote
Hi!

Now that another issue has been fixed by your team related to my settings, I can now confirm that this solution works flawlessly via a SSH channel.

However, maybe another question related to that:

Is there a way, using the profiler, to see the execution flow? I can see that something got hit 3 times, but I sometimes have a hard time figuring out what code executed the procedure where the line got hit.


Thanks!

Take care,

Fred
View user's profileFind all posts by fgiassonSend private message


Joined: 30 Jun 2009
Posts: 80
Reply with quote
@dmitri

Can debugbreak() (or dbg) be used to dump profile data to disk, similar to xdebug?

Thanks,
Temuri
View user's profileFind all posts by temuriSend private message


Joined: 05 Aug 2013
Posts: 30
Reply with quote
Select one of profile results, right click that result and you will get Export option. After that you can export to xml and csv. Image is from v10.



@dmitri Is there any way we can auto save this data either from IDE or from php.ini, setting something like debugger.profiler_output_dir?!
View user's profileFind all posts by phpstorm7Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 7857
Reply with quote
Neither profiler nor debugger store anything on the server side, so php.ini can't help.
But you can access profiler's API, fetch collected data and store it anywhere you want to.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 05 Aug 2013
Posts: 30
Reply with quote
Where can I find information about profiler's API?
View user's profileFind all posts by phpstorm7Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 7857
Reply with quote
for example here:
http://forum.nusphere.com/php-code-coverage-t3802.html
although the topic is entitled code coverage, it works with nothing else but profiler API

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 30 Jun 2009
Posts: 80
Reply with quote
@phpstorm7
I was NOT referring to right-click -> SAVE from IDE. I need an automated profiler output to disk, similar to XDebug's output that you can later view with wincachegrind.

@dmitri
Is it possible to generate profiling information with debugbreak() if IDE/debug listener isn't running anywhere and redirect output to disk?

Thanks!
View user's profileFind all posts by temuriSend private message


Joined: 05 Aug 2013
Posts: 30
Reply with quote
dmitri wrote:
for example here:
http://forum.nusphere.com/php-code-coverage-t3802.html
although the topic is entitled code coverage, it works with nothing else but profiler API

This was big help. At start I was still puzzled where did api calls like dbg_get_all_module_names, dbg_get_profiler_results came from. This wasn't documented anywhere but as it turns out, using google, there was even code example years ago when debugger was free extension. That link is dead now so I think it would be good idea to make sticky post somewhere and mention this in debugger documentation FAQ

@temuri
It worth pointing out that dbg_get_profiler_results will return array ONLY if profiler was executed!
View user's profileFind all posts by phpstorm7Send private message


Joined: 30 Jun 2009
Posts: 80
Reply with quote
@dmitri

Got a few questions for you:

1. What does dbg_startprofiler() do and what are the call arguments
2. Is it possible to use the combination of dbg_startprofiler() / dbg_stopprofiler() around a piece of code I want to profile and then use dbg_get_profiler_results($results) to retrieve profiling data
3. I wrote a simple PHP socket listener hoping to capture the raw profiling output sent by debugbreak('1@myHost:7777;d=0,p=1,c=0') but I got the following error:

DBG 5.0.8
Failed to start DBG session
Reason: debugger internal protocol error

I'm trying to use dbg in the same way as XDebug profiler. I want to be able to dump raw profiling data to a file on disk, WITHOUT having to run dbg listener. I am hoping that if I manage to get that done, I'd be able to write a tool similar to wincachegrind, thus improving PHPEd's profiling ability. I also want to eliminate the network transfer between the web server and my Windows-base development workstation where PHPEd listener is running.

Please provide some research direction for me or share the details of dbg's undocumented features.

Thanks,
Temuri
View user's profileFind all posts by temuriSend private message
Remote profiling
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 2  

  
  
 Reply to topic