NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Limiting deep for profiling


Joined: 09 Jun 2009
Posts: 6
Reply with quote
Hi everybody,

I am trying to use the profiler on my project but the result go too deeper. I mean that all the line of all the included file are also profiled. And the result is that a special line in a library file take all the time.

Is there a simple way to know which line of the main script is calling this library ?

Or better, is there a simple way to sum the total time that the script is consuming on each line of the main script that I am profiling ?


For example, here's a simple case:

scriptA.php
Code:

<?php
include "scriptB.php" ;

for($i = 0 ; $i < 10 ; $i++){
  oneFunction() ;
}
?>


scriptB.php
Code:

<?php
function oneFunction(){
    for($j = 0 ; $j < 10 ; $j++){
        sleep(1000);
    }
}
?>


The profiler will say that sleep (scriptB) is the line which consume the more time... And for me, the interesting thing is to know that the call to oneFunction() (scriptA) is consuming a lot of time.


Last edited by TSnarfK on Thu Jun 11, 2009 6:08 pm; edited 1 time in total
View user's profileFind all posts by TSnarfKSend private message


Joined: 09 Jun 2009
Posts: 6
Reply with quote
Ok, for the first point (knowing which line of the main script is calling the consuming line), I can do this way :

- putting a breakpoint on the consuming line
- running debug session and run to cursor (F4)
- then looking at the call stack

Any idea for the second point ?
View user's profileFind all posts by TSnarfKSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Quote:
The profiler will say that sleep (scriptB) is the line which consume the more time... And for me, the interesting thing is to know that the call to oneFunction() (scriptA) is consuming a lot of time.

1. you can EXCLUDE (see Minus button) the line from the results
2. you can switch betwenn 3 modes of the profiler: [M] - modules, [L] - lines, and [F] functions. If you check [M] modules, you'll see your module with its functions and lines inside.

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


Joined: 09 Jun 2009
Posts: 6
Reply with quote
Hi,

First of all, thank you for your reply. I already use these different modes. But I still need more information.

The exclude function doesn't help me either.
It could have help me a lot if the time of the excluded line was reported at a upper level.

I mean if I have this information :

Code:

Line ; Number of call ; Mean Time ; Total Time
"sleep(1000);" ; 100 ; 1 000 ; 100 000
"oneFunction()" ; 10 ; 0.1 ; 1


When excluding the "sleep(1000);" Line, I should obtain a thing like :
Code:

Line ; Number of call ; Mean Time ; Total Time
"oneFunction()" ; 10 ; 10 000.1 ; 100 001


Like this I can see that there's two problems :
- the sleep function take too much time so I can try to optimize it
- the oneFunction is called too many time so I can try to limit the number of call of this function

I think that what I really need is a complete call tree with the cumulated time at each step of the tree.
It might present like this maybe :
Code:

Line ; Number of call ; Mean Time ; Total Time ;
+  "oneFunction()" ; 10 ; 10 000.1 ; 100 001
--> "sleep(1000);" ; 10 ; 1 000 ; 10 000
--> "for($j = 0 ; $j < 10 ; $j++){" ;  1 ; 0.1 ; 0.1


After searching in the forum, I saw that it was already discussed here : plans-on-improving-the-profiler-t3801.html?highlight=profiling
In my point of view, even if this profiling is very slow, it might help a lot in profiling phase and will be a real added value for a tool like PHPEd.
In fact, I will be glad to pay the price of one license just for such a functionality.

I am not sure to be clear enough with this very basic example but I can give one more complex if you are not convinced. In real world, there can be more level in calls and the oneFunction() might also be called at different point in the same script so we have to find which call is the guilty one. With cumulated time, we have the answer immediately.
View user's profileFind all posts by TSnarfKSend private message
Limiting deep for 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 1  

  
  
 Reply to topic