Performance impact of using functions in WordPress?

I have a website that generates lots of dynamic contents. I’m facing performance issues even on my localhost, on a Corei7 processor.

I’ve tried to disable every unnecessary plugin, and ran p3 performance profiler to see the results. The resulting charts show that most of the loading time is spent on WordPress’s core (not plugins).

I’m using simple functions like if() and bloginfo('name') and call metadatas like get_post_meta() and the_permalink() a lot of times on my pages, one could say maybe up to 50 functions in each page.

These functions seem very simple, however i’m not sure how much impact do they have on loading time.

Is there a way to find out which parts of the page consume the most time? or is there a general guide to understand how much impact does these functions have on WordPress?

Thanks are in orders.

2 Answers
2

The overhead of PHP function as a mechanism is minimal. After all nearly everything going on is function calls. On a reasonable hardware you will have to ramp up function calls into thousands and tens of thousands to generate significant overhead (as opposed to doing same things with less function calls involved).

Worth noting that PHP profilers tend to overestimate the impact of function calls. Xdebug is especially eager to do that. More so just having Xdebug enabled can slow things down in environment heavy on function calls.

P3 profiler uses PHP ticks mechanism to profile, which is highly unreliable.

For any realistic outlook into performance you need to use a profiler that works on PHP engine level, such as Xdebug or Blackfire. In lack of such your performance troubleshooting options are very limited and basically amount to stuffing code with timers and ripping it apart until you figure out the slow part.

Leave a Comment