0

I am profiling a PHP website that seems a little slower than it should be with XDebug.

I checked the profile information with KCacheGrind and according to that, 80% + of the load time is caused by fopen.

However, when I add statements to the code before and after the fopen call to measure how long it is taking, it does not seem to be taking even close to the 80% reported by XDebug.

This method reports that it is taking around 2 seconds to complete the fopen call, the page is taking around 25 seconds to load - a large jump from the 80% reported by XDebug.

Is it really the fopen call slowing everything down and if not, how can I find out what is?

If it is not, how can I get more accurate information from XDebug?

Edit: It seems that although the call completes, it is still counted by XDebug as "current" until the connection is closed and it hangs until it times out. After manually closing the connection the stats seem to be a bit better.

Darren S
  • 83
  • 1
  • 9
  • fopen() is a filesystem call, which means it is likely to be slow – Mark Baker Jun 05 '13 at 16:09
  • Relatively slow. That does not mean it is causing a 20 second hang that cannot be accounted for. Checking the time before and after the fopen call suggests that XDebug is wrong - XDebug says around 20 seconds is fopen, printing the time out before and after the function that includes fopen suggests the entire function takes around 2 seconds. I am more inclined to believe the data from XDebug is inaccurate. – Darren S Jun 05 '13 at 16:09
  • Don't forget that xdebug is itself an overhead (you shouldn't use it in a production system for precisely that reason)... but all its call times should be proportional. While 20s reported by xdebug may not be the same as 2s just logging the time with microtime(), it is still indicating that fopen() is one call that takes a long time to execute – Mark Baker Jun 05 '13 at 16:49
  • @MarkBaker This is all from the same, non-production server. XDebug may add around a second to the load time, but it is not noticable. If I go fopen -> echo content -> die, it takes about 2 seconds for the page to load. If I remove the die statement, it takes another 23 seconds and fopen does not seem to be called again. XDebug is almost certainly wrong. This is more likely than not something else causing it to run slowly and XDebug isn't catching it. – Darren S Jun 05 '13 at 16:59

0 Answers0