note 43040 added to function.register-tick-function

From: Date: Mon, 07 Jun 2004 17:16:49 +0000
Subject: note 43040 added to function.register-tick-function
Groups: php.notes 
Request: Send a blank email to php-notes+get-70405@lists.php.net to get a copy of this message
Here's a nice function if you want to check how often your functions are getting called to make sure there aren't any useless files being included. Just place the first script at the top of the beginning of your script (possibly using auto_prepend_file) and the second script at the end of your script (possibly using auto_append_file). Script #1: <? function &watch_functions_tick($do_tick=true) { static $funcs = array(); static $last_func; if ($do_tick) { $trace = debug_backtrace(); $func = $trace[1]['function']; if ($trace[1]['class']) $func = $trace[1]['class'].$trace[1]['type'].$func; if ($func != $last_func && $func !== 'watch_functions_tick' && $func != 'unknown' && $func) { $funcs[$func]++; $last_func = $func; } elseif (!$func || $func = 'unknown') { $last_func = ''; } $funcs['__TICK_COUNT__']++; } else { return $funcs; } } declare (ticks=1); ?> Script #2: <? print_r(watch_functions_tick(false)); ?> -- Michael Bailey (http://www.jinxidoru.com) ---- Manual Page -- http://www.php.net/manual/en/function.register-tick-function.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43040 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43040&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43040&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70405) next »