Jump to content

Performance question


Stikki
 Share

Recommended Posts

Howdy

So i'v been checking core modules past month now? It all looks good and i figured out this and that, but then i saw there this:

/**
 * Return the web accessible URL to this Pagefile
 *
 */
public function url() {
	return self::isHooked('Pagefile::url()') ? $this->__call('url', array()) : $this->___url();
}

/**
 * Hookable version of url() method
 *
 */
protected function ___url() {
	return $this->pagefiles->url . $this->basename; 	
}

When creating module or what ever it is, how often and when should i consider using local vs backbone(wire) methods? Is there how huge impact in processing if everything is driven trough backbone? Is this some old code that is still there and everything should be driven via backbone nowdays?

Thanks for possible answers :)

Link to comment
Share on other sites

Sorry don't understand the question. Hook able methods always have some overhead but most of the time it's benefits over performance cause it's so minor you woNT notice. Maybe if a method gets potentially called 1000 times a request you may want to take that into consideration.

This code is brand new and not usual at all. I think Ryan does some magic here to account for performance here. But I'm not sure as I don't understand what it does exactly.

Link to comment
Share on other sites

Maybe if you could make another example. I think it's a little foggy for me what exactly you mean with local vs hooks or local vs hookable methods? Or do you mean wire('pages') vs $this->pages or $this->wire->pages?

Maybe Ryan could answer all those more competently after all.

Link to comment
Share on other sites

In nutshell it checks if url method is having anything hooked into it, if it dosen't, it calls real method locally directly from class and by passed hook system completely, cause there is nothing to run for, which obviously saves some micro seconds of time. So asking if there is any benchmark data, or something i could check and compare how big performance boost it actually is to check against local method vs run method via hooks (backbone).

But yeah if you don't understand question, this might be for Ryan, thanks anyways Soma.

Link to comment
Share on other sites

I know that this "trick" is used for just few methods - those that could be possible be run hundreds of times per request (like the url). So the performance issue is probably something that is probably not meaningful for normal hooks (where method is called only once or twice), but meaningful in commonly used methods.

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...