Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#43891 closed enhancement (invalid)

Performance improvement for WP_Query

Reported by: rnaby Owned by:
Priority: normal Milestone:
Component: Query Version:
Severity: normal Keywords: has-patch needs-testing
Cc: Focuses:

Description

WP_Query has some(10 I think) use of reset() function. But it has a performance drawback. So here I'm proposing to replace the PHP native reset() function with class method which will work with foreach() loop.

Here is the benchmark-
​http://sandbox.onlinephpfunctions.com/code/d16f2e69944643bd49ad3b2beb4d37ad23a2d742.

Attachments (1)

43891.diff​ (3.6 KB ) - added by rnaby 8 years ago.
The patch for the issue.

Download all attachments as: .zip

Change History (5)

@rnaby
8 years ago

The patch for the issue.

#1 @johnbillion
8 years ago

  • Keywords reporter-feedback added; 2nd-opinion dev-feedback removed
  • Severity major → normal
  • Version trunk

Thanks for the ticket and the patch, @rnaby, but I think your benchmarks are flawed. If you add judge($a, 'reset'); to the end of the test (after judge($a, '_reset'); you'll see that directly calling reset() is faster than the other methods. Your _reset() function incurs overhead that the reset() function doesn't.

Can you confirm?

Last edited 8 years ago by johnbillion (previous) (diff)

#2 @rnaby
8 years ago

@johnbillion Understood!

Last edited 8 years ago by rnaby (previous) (diff)

#3 @rnaby
8 years ago

  • Resolution → worksforme
  • Status new → closed

#4 @SergeyBiryukov
8 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review
  • Resolution worksforme → invalid
Note: See TracTickets for help on using tickets.