开发者

How do I interpret profiling logs of my zend web app?

开发者 https://www.devze.com 2023-03-16 14:04 出处:网络
I\'m just a newbiee with profiling web apps.Given a profile log file what info could I get? and how do I know where I need to work on to make my app faster.

I'm just a newbiee with profiling web apps.Given a profile log file what info could I get? and how do I know where I need to work on to make my app faster.

I have this sample zend application's ind开发者_JAVA百科ex page profile that I don't know how to interpret:

How do I interpret profiling logs of my zend web app?


The number you need is total cumulative time - ignore self (own) times, the call counts, and the average times.

Find a routine with high cumulative time where there are some functions it's calling that could be done less. Especially if those functions do I/O.

Another way is simply interrupt the script, manually, and record the call stack, several times. If you take a careful look at those stack samples, you will see exactly which lines of code are draining most of the time. More on that.


First thing to do would be sorting the results on cum. The biggest bottleneck is the one that takes longest. Then dig down and look what that routine is doing, and try to find loops containing other methods. Look at the hitcount (calls) of those nested methods and the time they took.

For example lets say MyFunc is taking longest, you look into it and you see it has a loop doing some stuff. Look in the loop you might see MyOtherFunc is called inside the loop, look at the table again and lookup MyOtherFunc. It was called 200 times? look if you can move MyOtherFunc out of the loop (does it need a changing variable as input?).

For example in pseudo-code if you see this:

FOR (MyVar = 0 TO GetItems().Count) {
  print GetItems()[MyVar].Name;
}

If GetItems returns 100 items, the method GetItems will be called 200 times. The profiler will point such a flaw out by the high hitcount. So you go in and cache the result in a local variable:

var TempVar = GetItems();
FOR (MyVar = 0 TO TempVar.Count) {
  print TempVar[MyVar].Name;
}

Now it will only be called once. Profile again and compare your results.

Warning: profiling can get addictive once you get the hang of it!

0

精彩评论

暂无评论...
验证码 换一张
取 消