Home » Php » php – Profiling advice – trying to pinpoint site loading issue

php – Profiling advice – trying to pinpoint site loading issue

Posted by: admin July 12, 2020 Leave a comment

Questions:

I’ve taken over a wordpress e-comm (although this question is more about profiling generally) site which has a performance issue which seemingly only affects one specific area in the admin section of the CMS. When trying to edit one particular type of product, which has a large number of attributes attached to it, the page effectively causes the browser to crash 99% of the time. I expected this to be down to MySQL queries causing the bottleneck, however when I profiled the db, I got the following results:

Total Queries: 174 – Total Time Of MySQL Queries: 0.11370

This suggests the bottleneck is happening elsewhere, but I’m not sure where it could be. If I run YSlow on the page, there is nothing drastic there which would explain the issue, although there are around 20 scripts and stylesheets loaded, so some optimisation could be done there. I’m going to enable an opcode cache library which will improve PHP performance, but is there anything else I can do to try to identify the issue here? Thanks.

How to&Answers:

Use a Profiler like Xdebug…if the problem is not their in database my be PHP has the problem..find out which part of code is taking longer…Xdebug will tell you time taken per function call as well as memory usase.

Answer:

Last time I profiled wordpress, it took me a dozen microtime(1)-based calculations to spot the place that took half of 2.5 seconds loading time. It was loading and parsing of .mo localization file.

Also considerable gain was from installing APC cache, as it turned out that wordpress is a heavy bloated monster consumes a lot of time to parse it’s codes.

Answer:

I would

  • Use Firebug‘s or Chrome’s Net panel to see if it’s the page or the JavaScript/CSS/imges that are causing the slowdown (front-end)
  • Use curl to see how long the page takes: time curl -b PHPSESSID=123 http://example.com/wp-admin/
  • Enable/install Xdebug and turn profiling on. Use KCachegrind to see which functions are causing the biggest delays.

Answer:

firebug (add-on to firefox) is the best tool that I know to locate such issues. You can also install another pluging called “page speed“. it will show you exactly which part takes longer to load.
another option is to debug your code with “time” printing and see which has the biggest time-gap:
http://php.net/manual/en/function.microtime.php