[wp-trac] [WordPress Trac] #58291: Speed up WordPress hooks addition/removal by ~20%

WordPress Trac noreply at wordpress.org
Thu Jun 22 11:54:06 UTC 2023


#58291: Speed up WordPress hooks addition/removal by ~20%
-------------------------------------------+------------------------------
 Reporter:  bor0                           |       Owner:  (none)
     Type:  defect (bug)                   |      Status:  new
 Priority:  normal                         |   Milestone:  Awaiting Review
Component:  Plugins                        |     Version:  trunk
 Severity:  normal                         |  Resolution:
 Keywords:  changes-requested needs-patch  |     Focuses:  performance
-------------------------------------------+------------------------------

Comment (by schlessera):

 Changing the function here into a static method (and potentially breaking
 BC) is not needed here. Static methods are not generally faster than
 function calls, the above static-faster.php file is just providing wrong
 results because it does not correctly benchmark the part of the PHP code
 it should.

 I've adapted the benchmark file to be more correct by adding a warm-up
 call and by doing more iterations to average out random fluctuations. The
 result can be seen here: https://3v4l.org/A7Blr. So a function call is on
 average more than twice as fast as a function call.

 Therefore, I suggest to revert the change from function call to static
 method, as this should get rid of the potential BC break and even further
 improve the performance.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58291#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list