[wp-trac] [WordPress Trac] #23855: Leave Shortcode functions early, if there's no Shortcode delimiter
WordPress Trac
noreply at wordpress.org
Wed Feb 12 19:43:00 UTC 2014
#23855: Leave Shortcode functions early, if there's no Shortcode delimiter
-------------------------+------------------------------
Reporter: TobiasBg | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Shortcodes | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses: performance
-------------------------+------------------------------
Changes (by TobiasBg):
* focuses: => performance
Comment:
I finally had some time to refresh the patch (for develop.svn., and with
`if-{}`) and also to write a quick script to measure the execution time of
the suggested change: [attachment:23855.test.php]. Just run this on the
patched and unpatched versions of `shortcodes.php` (by simply putting
[attachment:23855.test.php] in `src/`).
It runs the three functions in question on a dummy text with two
Shortcodes that appear twice, and on a dummy text that does not have
Shortcodes.
|| ||Text with Shortcodes||Text without Shortcodes||
||`has_shortcode()`||0.298s — unpatched||0.297s — unpatched||
|| ||0.409s — [attachment:23855.2.patch]||0.259s —
[attachment:23855.2.patch]||
||`do_shortcode()`||13.379s — unpatched||4.497s — unpatched||
|| ||13.309s — [attachment:23855.2.patch]||0.253s —
[attachment:23855.2.patch]||
||`strip_shortcode()`||7.524s — unpatched||4.431s — unpatched||
|| ||7.521s — [attachment:23855.2.patch]||0.244s —
[attachment:23855.2.patch]||
The patched version appears to be much faster for `do_shortcode()` and
`strip_shortcode()` (factor 15 to 20) and not so much with
`has_shortcode()`, in texts without Shortcodes. For texts with Shortcodes,
the execution time remains pretty much constant.
So, adding this check to `has_shortcode()` might not be necessary.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/23855#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list