Here's a way to do it so that you have to add only one line to each function you want to track, plus you won't have to alter the function's return value:
function function_count($func = '')
{
static $ct = array();
if ($func) {
@$ct[$func]++;
} else {
foreach ($ct as $key => $val) {
echo $key . '(): ' . $val . '<br />';
}
}
}
function some_function()
{
function_count(__FUNCTION__);
// Your code
}
function other_function()
{
function_count(__FUNCTION__);
// Your code
}
for ($i = 0; $i < 16; $i++) {
some_function();
}
for ($i = 0; $i < 8; $i++) {
other_function();
}
function_count();