Ticket #46505: 46505.diff
File 46505.diff, 3.0 KB (added by , 5 years ago) |
---|
-
tests/phpunit/includes/wp-profiler.php
18 18 */ 19 19 20 20 class WPProfiler { 21 var$stack;22 var$profile;21 public $stack; 22 public $profile; 23 23 24 24 /** 25 25 * PHP5 constructor. 26 26 */ 27 function __construct() {27 public function __construct() { 28 28 $this->stack = array(); 29 29 $this->profile = array(); 30 30 } 31 31 32 function start( $name ) {32 public function start( $name ) { 33 33 $time = $this->microtime(); 34 34 35 35 if ( ! $this->stack ) { … … 60 60 61 61 } 62 62 63 function stop() {63 public function stop() { 64 64 $item = array_pop( $this->stack ); 65 65 $time = $this->microtime( $item['start'] ); 66 66 $name = $item['name']; … … 106 106 } 107 107 } 108 108 109 function microtime( $since = 0.0 ) {109 public function microtime( $since = 0.0 ) { 110 110 list($usec, $sec) = explode( ' ', microtime() ); 111 111 return (float) $sec + (float) $usec - $since; 112 112 } 113 113 114 function log_filter( $tag ) {114 public function log_filter( $tag ) { 115 115 if ( $this->stack ) { 116 116 global $wp_actions; 117 117 if ( $tag == end( $wp_actions ) ) { … … 123 123 return $arg; 124 124 } 125 125 126 function log_action( $tag ) {126 public function log_action( $tag ) { 127 127 if ( $this->stack ) { 128 128 @$this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ] ++; 129 129 } 130 130 } 131 131 132 function _current_action() {132 public function _current_action() { 133 133 global $wp_actions; 134 134 return $wp_actions[ count( $wp_actions ) - 1 ]; 135 135 } 136 136 137 function results() {137 public function results() { 138 138 return $this->profile; 139 139 } 140 140 141 function _query_summary( $queries, &$out ) {141 public function _query_summary( $queries, &$out ) { 142 142 foreach ( $queries as $q ) { 143 143 $sql = $q[0]; 144 144 $sql = preg_replace( '/(WHERE \w+ =) \d+/', '$1 x', $sql ); … … 150 150 return; 151 151 } 152 152 153 function _query_count( $queries ) {153 public function _query_count( $queries ) { 154 154 // this requires the savequeries patch at https://core.trac.wordpress.org/ticket/5218 155 155 $out = array(); 156 156 foreach ( $queries as $q ) { … … 163 163 return $out; 164 164 } 165 165 166 function _dirty_objects_count( $dirty_objects ) {166 public function _dirty_objects_count( $dirty_objects ) { 167 167 $out = array(); 168 168 foreach ( array_keys( $dirty_objects ) as $group ) { 169 169 $out[ $group ] = count( $dirty_objects[ $group ] ); … … 171 171 return $out; 172 172 } 173 173 174 function array_add( $a, $b ) {174 public function array_add( $a, $b ) { 175 175 $out = $a; 176 176 foreach ( array_keys( $b ) as $key ) { 177 177 if ( array_key_exists( $key, $out ) ) { … … 183 183 return $out; 184 184 } 185 185 186 function array_sub( $a, $b ) {186 public function array_sub( $a, $b ) { 187 187 $out = $a; 188 188 foreach ( array_keys( $b ) as $key ) { 189 189 if ( array_key_exists( $key, $b ) ) { … … 193 193 return $out; 194 194 } 195 195 196 function print_summary() {196 public function print_summary() { 197 197 $results = $this->results(); 198 198 199 199 printf( "\nname calls time action filter warm cold misses dirty\n" );