// Start profiling database queries Yii::beginProfile('Database Queries'); // Perform some database queries $users = User::find()->all(); // Stop profiling database queries Yii::endProfile('Database Queries');
class SiteController extends Controller { public function actionIndex() { // Start profiling controller action Yii::beginProfile('Index Action'); // Do some stuff // Stop profiling controller action Yii::endProfile('Index Action'); } }In this example, the Yii controller action for the site index page is being profiled. The beginProfile method is called at the start of the action, and the endProfile method is called at the end. The endProfile method is part of the YiiBase class in the Yii framework, which is a package library included in the core Yii framework.