$section = new ProfileSection( __METHOD__ ); * * @param string $name Name of the function to profile */ public function __construct( $name ) { $this->name = $name; // Use Profiler member variable directly to reduce overhead if ( Profiler::$__instance === null ) { Profiler::instance(); } if ( !( Profiler::$__instance instanceof ProfilerStub ) ) { $this->enabled = true; Profiler::$__instance->profileIn( $this->name ); } } function __destruct() { if ( $this->enabled ) { Profiler::$__instance->profileOut( $this->name ); } } }