Make WordPress Core


Ignore:
Timestamp:
10/02/2015 04:25:40 AM (11 years ago)
Author:
wonderboymusic
Message:

Shortcodes/Formatting: Add PCRE Performance Testing

  • Move pattern from wptexturize() into a separate function.
  • Move pattern from wp_html_split() into a separate function.
  • Beautify code for wp_html_split().
  • Remove unnecessary instances of /s modifier in patterns that don't use dots.
  • Add tests/phpunit/data/formatting/whole-posts.php for testing larger strings.
  • Add function benchmark_pcre_backtracking().
  • Add tests for wp_html_split().
  • Add tests for wptexturize().
  • Add tests for get_shortcode_regex().

Props miqrogroove.
Fixes #34121.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/shortcode.php

    r34745 r34761  
    617617                );
    618618        }
     619
     620        /**
     621         * Automated performance testing of the main regex.
     622         *
     623         * @dataProvider data_whole_posts
     624         */
     625        function test_pcre_performance( $input ) {
     626                $regex = '/' . get_shortcode_regex() . '/';
     627                $result = benchmark_pcre_backtracking( $regex, $input, 'match_all' );
     628                return $this->assertLessThan( 200, $result );
     629        }
     630
     631        function data_whole_posts() {
     632                require_once( DIR_TESTDATA . '/formatting/whole-posts.php' );
     633                return data_whole_posts();
     634        }
    619635}
Note: See TracChangeset for help on using the changeset viewer.