-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- performance require_once should be called only once for shared plug…
…ins #280
- Loading branch information
Showing
1 changed file
with
6 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51e0d5c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Optimizations" like these are very poisonous.
On small samples (under 1'000 attempts), straight
require_once $file
is no slower thanif(!is_callable(...)) require_once $file
even on a very old versions of PHP, but code readability suffers.https://3v4l.org/b5HCA
51e0d5c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. But this comes from a real use case (see the associated issue #280), profiling the "date_format" modifier with 300 calls on a template. Real profiling giving 100 ms, optimized went to 2 ms. Perhaps some weird scenario (SAPI, environment, I didn't test everything) but seemed a good performance gain.
51e0d5c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then move require_once away from function. Will be much better performance, as it were in multiple instances. Why moving it inside a function and then guarding with obnoxious flow control switches?
51e0d5c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding to that, the use case provided in #280 is wastly different from the current master implementation.
Compare local variable dereference with a registered functions' table lookup?
51e0d5c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the commit now. If that's indeed faster, then nice one. Thanks.