Changeset 640509
- Timestamp:
- 12/17/2012 12:52:26 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-log-in-browser/trunk/README.txt
r640503 r640509 30 30 For example, to log all your main query's query_vars: 31 31 32 ` ``add_filter( 'pre_get_posts', 'log_wp_query', 10000 );32 `add_filter( 'pre_get_posts', 'log_wp_query', 10000 ); 33 33 34 34 function log_wp_query( $query ) { … … 37 37 38 38 return $query; 39 }` ``39 }` 40 40 41 41 = Filters = … … 61 61 Example 1: Sequential use, log manually. 62 62 63 ` ``browser()->timer( 'Mega loop' );63 `browser()->timer( 'Mega loop' ); 64 64 for ( $i = 0; $i < 1000000; $i++ ) { 65 65 //do something 66 66 } 67 67 $time = browser()->timer( 'Mega loop' ); 68 browser()->log( $time, 'The mega loop took:' );` ``68 browser()->log( $time, 'The mega loop took:' );` 69 69 70 70 Example 2: Start and end in different places, log automatically. 71 71 72 ` ``add_action( 'posts_selection', 'start_timer', 100 );72 `add_action( 'posts_selection', 'start_timer', 100 ); 73 73 add_filter( 'the_posts', 'end_timer', 1, 2 ); 74 74 … … 80 80 browser()->timer( 'Main query time', true ); 81 81 return $posts; 82 }` ``82 }` 83 83 84 84 *This is not a good way of measuring how much time a query takes to run, it's just to illustrate how to use the timer.* … … 92 92 Example: 93 93 94 ` ``Browser()->memory( 'testing' );94 `Browser()->memory( 'testing' ); 95 95 $test = array(); 96 96 for ( $i = 0; $i < 100; $i++ ) { … … 105 105 $test[$i] = md5( rand( 1, $i ) ); 106 106 } 107 Browser()->memory( 'testing', true );` ``107 Browser()->memory( 'testing', true );` 108 108 109 109 == Installation ==
Note: See TracChangeset
for help on using the changeset viewer.