Scripts execution time

Hi guys!

I decide to test my scripts and to see how much time it requires for execute.

In config:


'components'=>array(

	'log'=>array(

		'class'=>'CLogRouter',

		'routes'=>array(

			array(

				'class'=>'CProfileLogRoute',

			),

Then in main index.php:


<?php


// change the following paths if necessary

$yii=dirname(__FILE__).'/../yii/framework/yii.php';

$config=dirname(__FILE__).'/protected/config/main.php';


// remove the following lines when in production mode

defined('YII_DEBUG') or define('YII_DEBUG',true);

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);


require_once($yii);


Yii::beginProfile('blockID');


Yii::createWebApplication($config)->run();


Yii::endProfile('blockID');

And that what I saw. As you can see all queries executes fairly fast. But I’m interesting in first line: “blockID … 0.1385s”. I can’t understand what is it means. Is it the time for executing the beginProfile(‘blockID’) command itself ?

That’s the time that is spent between the beginProfile and endProfile calls. So in your case: The complete time required for Yii::createWebApplication($config)->run();.

Is it the long time and need to optimize?

This value alone is of not much use. You should better use e.g. ab (Apache Benchmark tool) to test the requests per seconds and compare that to load you expect. Profiling is rather to find out bottlenecks of your application (like: Where is most time spent?)