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: 7887
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: 79
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
Site Admin

Joined: 13 Jul 2003
Posts: 7887
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
Site Admin

Joined: 13 Jul 2003
Posts: 7887
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: 79
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
Site Admin

Joined: 13 Jul 2003
Posts: 7887
Reply with quote
Indeed the functions are for profiling part(s) of code.
As of protocol, you'll waste a lot of time trying to reengineer it (which is not so legal btw). And what is it for? You will try to re-implement all logic behind dbglistener and PhpED? In what direction data exported from PhpED will differ from data that would be stored by your potential interceptor that you're trying to develop?

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


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

No, I am not going to do that. It was an attempt out of desperation. All I want is to be able to profile my code without running dbg listener (just the way XDebug does).

So, I'm looking for your help. Can you answer the following question?

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.

That's all.
View user's profileFind all posts by temuriSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7887
Reply with quote
I don't see any advantages of storing data in a file on the server. You'll have to get it back to the client, then analyze and what you'll have in the result is exactly what you already have in the IDE. Why bother? If you think that the IDE gets more raw data and can show more than it shows, you're wrong.

As of those functions, they are just filters to temporary disable/enable gathering time. They do neither start nor stop the profiler. Profiler as well as debugger can't work without connection to the IDE. It's IDE sends commands and receives the results.

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


Joined: 30 Jun 2009
Posts: 79
Reply with quote
I'll explain my goal.

I was running apache benchmark (ab) tool with various requests/concurrency settings. I was using XDebug output to analyze the performance behaviour delta in several classes (class loader, ACL, Models, Navigation) under growing server load.

Then I asked myself - can I do it with dbg, avoiding remote connection to the listener.

Do you follow my logic?

So, it would be very nice if dbg could dump profiling results to file on disk. I don't see that as an impossible task, because PHPEd itself does not measure anything. It should be just a matter of redirecting output.

Thanks
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