Php > Miscellaneous
Function Watcher
Function Watcher // tick function for watching functions // if $ret_funcs is true, a tick is not registered, // but instead, the function list is returned. function watch_functions_tick($ret_funcs=false) { static $funcs = array(); // do tick if (!$ret_funcs) { // get the current function from debug_backtrace $trace = debug_backtrace(); $trace = $trace[1]; $func = $trace['function']; if ($trace['class']) $func = $trace['class'].$trace['type'].$func; // as long as the given function is a valid one, add it to the array if ($func !== 'watch_functions_tick' && $func != 'unknown' && $func) { $funcs[$func]++; $funcs['__TICK_COUNT__']++; } // return the function array } else { return $funcs; } } // output the function list with the number of ticks each // function received as well as the percentage of the total // ticks it represents function watch_functions_output() { // retrieve the function list $funcs = watch_functions_tick(true); $tick_count = $funcs['__TICK_COUNT__']; arsort($funcs); // add the percentage onto each function entry foreach ($funcs AS $k => $v) { $funcs[$k] = sprintf('%d (%.2f%%)', $funcs[$k], $funcs[$k]*100/$tick_count); } // display the function list print "
"; print_r($funcs); print "
"; } // start the ticking register_tick_function('watch_functions_tick'); ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage