Jump to content

response speed of selector


sakkoulas
 Share

Recommended Posts

Hello everybody 

i don't know if this is a dumb idea, but is it possible (or it is not necessary) to test the response speed of selectors. for example 

$pages->get('/page/')->children('date>=$date');

$pages->find('template=name, date>=$date');

$pages->get('/page/')->find('date>=$date')

which of those three selectors is faster, 

sorry again if this is dumb question.

thanks 
Link to comment
Share on other sites

Assuming those 3 result in identical results, most likely the 2nd one would be fastest since it is 1 API call rather than 2. The 1st one would be the second fastest since $page->children() is faster than $page->find, as it doesn't have to consider hierarchy beyond 1 level. These are my best guesses anyway. If you want to test them out, take a look at Debug::timer() (/wire/core/Debug.php). Also note you'll want to use double quotes for your selectors as the $date variable would not be dereferenced in single quotes. 

  • 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...