Make WordPress Core

Ticket #46505: 46505.diff

File 46505.diff, 3.0 KB (added by andizer, 5 years ago)
  • tests/phpunit/includes/wp-profiler.php

     
    1818*/
    1919
    2020class WPProfiler {
    21         var $stack;
    22         var $profile;
     21        public $stack;
     22        public $profile;
    2323
    2424        /**
    2525         * PHP5 constructor.
    2626         */
    27         function __construct() {
     27        public function __construct() {
    2828                $this->stack   = array();
    2929                $this->profile = array();
    3030        }
    3131
    32         function start( $name ) {
     32        public function start( $name ) {
    3333                $time = $this->microtime();
    3434
    3535                if ( ! $this->stack ) {
     
    6060
    6161        }
    6262
    63         function stop() {
     63        public function stop() {
    6464                $item = array_pop( $this->stack );
    6565                $time = $this->microtime( $item['start'] );
    6666                $name = $item['name'];
     
    106106                }
    107107        }
    108108
    109         function microtime( $since = 0.0 ) {
     109        public function microtime( $since = 0.0 ) {
    110110                list($usec, $sec) = explode( ' ', microtime() );
    111111                return (float) $sec + (float) $usec - $since;
    112112        }
    113113
    114         function log_filter( $tag ) {
     114        public function log_filter( $tag ) {
    115115                if ( $this->stack ) {
    116116                        global $wp_actions;
    117117                        if ( $tag == end( $wp_actions ) ) {
     
    123123                return $arg;
    124124        }
    125125
    126         function log_action( $tag ) {
     126        public function log_action( $tag ) {
    127127                if ( $this->stack ) {
    128128                        @$this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ] ++;
    129129                }
    130130        }
    131131
    132         function _current_action() {
     132        public function _current_action() {
    133133                global $wp_actions;
    134134                return $wp_actions[ count( $wp_actions ) - 1 ];
    135135        }
    136136
    137         function results() {
     137        public function results() {
    138138                return $this->profile;
    139139        }
    140140
    141         function _query_summary( $queries, &$out ) {
     141        public function _query_summary( $queries, &$out ) {
    142142                foreach ( $queries as $q ) {
    143143                        $sql = $q[0];
    144144                        $sql = preg_replace( '/(WHERE \w+ =) \d+/', '$1 x', $sql );
     
    150150                return;
    151151        }
    152152
    153         function _query_count( $queries ) {
     153        public function _query_count( $queries ) {
    154154                // this requires the savequeries patch at https://core.trac.wordpress.org/ticket/5218
    155155                $out = array();
    156156                foreach ( $queries as $q ) {
     
    163163                return $out;
    164164        }
    165165
    166         function _dirty_objects_count( $dirty_objects ) {
     166        public function _dirty_objects_count( $dirty_objects ) {
    167167                $out = array();
    168168                foreach ( array_keys( $dirty_objects ) as $group ) {
    169169                        $out[ $group ] = count( $dirty_objects[ $group ] );
     
    171171                return $out;
    172172        }
    173173
    174         function array_add( $a, $b ) {
     174        public function array_add( $a, $b ) {
    175175                $out = $a;
    176176                foreach ( array_keys( $b ) as $key ) {
    177177                        if ( array_key_exists( $key, $out ) ) {
     
    183183                return $out;
    184184        }
    185185
    186         function array_sub( $a, $b ) {
     186        public function array_sub( $a, $b ) {
    187187                $out = $a;
    188188                foreach ( array_keys( $b ) as $key ) {
    189189                        if ( array_key_exists( $key, $b ) ) {
     
    193193                return $out;
    194194        }
    195195
    196         function print_summary() {
     196        public function print_summary() {
    197197                $results = $this->results();
    198198
    199199                printf( "\nname                      calls   time action filter   warm   cold misses  dirty\n" );