Performance impact of using functions in WordPress?

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