[wp-trac] [WordPress Trac] #35293: Emoji Regex in wp_encode_emoji() is wildly inaccurate

WordPress Trac noreply at wordpress.org
Thu Jul 13 13:32:43 UTC 2017


#35293: Emoji Regex in wp_encode_emoji() is wildly inaccurate
-------------------------------------+-----------------------
 Reporter:  pento                    |       Owner:  pento
     Type:  defect (bug)             |      Status:  assigned
 Priority:  normal                   |   Milestone:  4.8.1
Component:  Emoji                    |     Version:  4.2
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+-----------------------

Comment (by pento):

 [attachment:35293-performance.php] tests the performance of the old and
 new approaches.

 These functions aren't used in directly user-facing situations, the
 closest we have is RSS feeds. `wp_staticize_emoji()` is run on each post
 in an RSS feed, to convert emoji characters to images. So, to simulate an
 RSS feed, the old and new versions of `wp_staticize_emoji()` were run 10
 times - once for each post in the feed. The time differences below are for
 10 runs of each function.

 (Percentages refer to the percentage of characters in the string that are
 emoji.)

 '''Short Posts (100 characters)'''

 0%: wp_staticize_emoji() is 2.5ms faster than wp_staticize_emoji2().
 1%: wp_staticize_emoji() is 0.1ms slower than wp_staticize_emoji2().
 10%: wp_staticize_emoji() is 0ms faster than wp_staticize_emoji2().
 50%: wp_staticize_emoji() is 0ms faster than wp_staticize_emoji2().

 '''Medium Posts (1000 characters)'''

 0%: wp_staticize_emoji() is 0ms faster than wp_staticize_emoji2().
 1%: wp_staticize_emoji() is 0.3ms slower than wp_staticize_emoji2().
 10%: wp_staticize_emoji() is 0.5ms slower than wp_staticize_emoji2().
 50%: wp_staticize_emoji() is 0.4ms slower than wp_staticize_emoji2().

 '''Long Posts (10,000 characters)'''

 0%: wp_staticize_emoji() is 0.1ms slower than wp_staticize_emoji2().
 1%: wp_staticize_emoji() is 42.1ms slower than wp_staticize_emoji2().
 10%: wp_staticize_emoji() is 55.5ms slower than wp_staticize_emoji2().
 50%: wp_staticize_emoji() is 132ms slower than wp_staticize_emoji2().

 '''Epic Posts (100,000 characters)'''

 0%: wp_staticize_emoji() is 0.9ms slower than wp_staticize_emoji2().
 1%: wp_staticize_emoji() is 3830.6ms slower than wp_staticize_emoji2().
 10%: wp_staticize_emoji() is 4555.5ms slower than wp_staticize_emoji2().
 50%: wp_staticize_emoji() is 11294.4ms slower than wp_staticize_emoji2().

 I ran the 50% numbers for fun, sadly, I don't expect many people to be
 writing huge posts that are half emoji. :-)

 The interesting numbers are the 0% and 1% cases, which I suspect would be
 the most common. For short and medium posts, the difference is negligible.
 For longer posts, however, the new approach is exponentially faster.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35293#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list