Changeset 1332

Show
Ignore:
Timestamp:
09/05/08 18:21:46 (3 months ago)
Author:
_ck_
Message:

0.2.2 now uses function trace feature available in bbPress 1.0

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bb-benchmark/trunk/_bb-benchmark.php

    r1243 r1332  
    66Author: _ck_ 
    77Author URI: http://bbShowcase.org 
    8 Version: 0.2.1 
     8Version: 0.2.2 
    99 
    1010License: CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/ 
     
    7777         
    7878        // print_r($bbdb->queries);      
    79         $test=$bbdb->queries; foreach (array_keys($test) as $key) {echo " # ".($key+1)." : ".round($test[$key][1],4)." seconds\n".ereg_replace("--","- - ",$test[$key][0])."\n\n";} 
     79        $test=$bbdb->queries;  
     80        foreach (array_keys($test) as $key) { 
     81                echo " # ".($key+1)." : ".round($test[$key][1],4)." seconds".(isset($test[$key][2]) ? "     function ".$test[$key][2] : "")."\n".ereg_replace("--","- - ",$test[$key][0])."\n\n"; 
     82        } 
    8083                         
    8184        echo "\n\n === executed files === \n"; 
     
    9396} 
    9497add_action('bb_foot', 'bb_benchmark_output',999); 
    95 add_action('bb_admin_footer', 'bb_benchmark_output'); 
     98add_action('bb_admin_footer', 'bb_benchmark_output',999); 
    9699 
    97100// global $bb_current_user;  if ($bb_current_user->data->bb_capabilities['keymaster']) : 
     
    118121add_action( 'bb_index.php', 'bb_benchmark_template_timer' ); 
    119122 
     123 
     124function bb_benchmark_get_caller() {            // not used here yet - just for reminder/storage 
     125        if ( !is_callable('debug_backtrace') ) {return '';}             // requires PHP 4.3+                     
     126 
     127        $bt = debug_backtrace(); $caller = ''; $tail= ''; 
     128 
     129        foreach ( $bt as $trace ) { 
     130                if ( @$trace['class'] == __CLASS__ ) 
     131                        continue; 
     132                elseif ( strtolower(@$trace['function']) == 'call_user_func_array' ) 
     133                        continue; 
     134                elseif ( strtolower(@$trace['function']) == 'apply_filters' ) 
     135                        continue; 
     136                elseif ( strtolower(@$trace['function']) == 'do_action' ) 
     137                        continue; 
     138                elseif ( strtolower(@$trace['function']) == 'query' ) {$tail=" (query) ".$tail; continue;} 
     139                elseif ( strtolower(@$trace['function']) == 'bb_query' ) {$tail=" (bb_query) ".$tail; continue;} 
     140                elseif ( strtolower(@$trace['function']) == 'bb_append_meta' )  {$tail=" (bb_append_meta) ".$tail; continue;} 
     141 
     142                $caller = $trace['function'].$tail; 
     143                break; 
     144        } 
     145                return $caller; 
     146} 
     147 
     148 
    120149?> 
  • bb-benchmark/trunk/readme.txt

    r1243 r1332  
    7171 
    7272* 0.2.1 : set priority to dead last so ALL queries are tracked in bb_foot, another BB_IS_ADMIN bug 
     73 
     74= Version 0.2.2 (2008-09-05) = 
     75 
     76* 0.2.2 : adds function trace available in bbPress 1.0 - would like to replace with enhanced/deeper trace someday