Profiling

Hi,

When running profiling inside a single function, what’s the best way to end profiling when there are multiple return statements?

What does Yii do in this situation:




function runMeh(){

	$key = 'MyProfileKey';

	Yii::beginProfile($key);

	if ( false )

		return true;

 		some complex code

      	if (some new stuff matches)

		return true;

	else

		lots of other returns and stuff

	if ( I am true sometimes)

		return true;


	Yii::endProfile($key);

	return false;

}



Would it end profiling cleverly on the return statement? or does it wait until all execution is complete as ?

I can’t decide which I would even want it to do tbh, as if I wanted to track something across lots of functions I wouldn’t want it to end on every return, but if it can see when the function is was initialized in returns, then I suppose that would be a clever way of doing it.

Anyone got any ideas? Or even a link to more detailed description of the profiling system?

I’ve determined it definitely does not end profiling properly on the return as placing it at the end of the function reports much longer times than when placed just before the return statement. So i guess it has to wait until… app end? process completion? Calling function completion? what’s the intended behaviour?