Juergen Posted December 13, 2022 Share Posted December 13, 2022 Hello @ all I am using a lot of hooking of methods and I want to optimize the performance of a module a little. In my case I use the following Hooks inside my modules init() method: public function init() { $this->addHookBefore('Page::render', $this, 'function1'); $this->addHookBefore('Page::render', $this, 'function2'); $this->addHookBefore('Page::render', $this, 'function3'); $this->addHookBefore('Page::render', $this, 'function4'); } As you can see, I am always hooking the same method (Page::render) to run different functions. The functions itself are declared outside of the init() method. My question: Would it have an impact on the performance if I would fe summarize function1 to function4 into one function (see below) or does it not matter? public function init() { $this->addHookBefore('Page::render', $this, 'summarizeFunction'); } protected function summarizeFunction() { $this->function1(); $this->function2(); $this->function3(); $this->function4(); } As you can see, I have only 1 hook left, that hooks into Page::render - not 4 as before. I have not try it, if there would be a significant performance boost or not. I only want to ask some other devs if they have experiences if this could be optimize the performance a little bit or not. Best regards 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now