Bohdan Vorona
Bohdan Vorona

Reputation: 725

System resources used by Yii app

How to see how much each AR query the database takes resources (operative and processor)?

Functions memory_get_usage() and memory_get_peak_usage() can't help us in this question.

Now I'm using:

ExecutionTime: <?=round(Yii::getLogger()->executionTime, 3); ?>;
MemoryUsage: <?=round(Yii::getLogger()->memoryUsage/1024/1024, 3)." MB"; ?>;

But this results for the whole application.

Upvotes: 1

Views: 123

Answers (2)

Olvathar
Olvathar

Reputation: 551

Perhaps you should install yii debug toolbar http://www.yiiframework.com/extension/yii-debug-toolbar/ . We found it pretty useful for profiling, once installed it's really simple to active

defined('YII_ENABLE_ERROR_HANDLER') or define('YII_ENABLE_ERROR_HANDLER', false);
//show profiler
defined('YII_DEBUG_SHOW_PROFILER') or define('YII_DEBUG_SHOW_PROFILER', false);
//enable profiling
defined('YII_DEBUG_PROFILING') or define('YII_DEBUG_PROFILING', false);
//trace level
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 0);
//execution time
defined('YII_DEBUG_DISPLAY_TIME') or define('YII_DEBUG_DISPLAY_TIME', false);
//debuging
defined('YII_DEBUG') or define('YII_DEBUG',true);

Think those lines were for sql profiling too. Were found with a few google searches but I can't find original URL. Sorry for that

You also should add it to config/main

'components'=>array(
    'log'=>array(
        'class'=>'CLogRouter',
        'routes'=>array(
                    array(
                        'class'=>'ext.yii-debug-toolbar.YiiDebugToolbarRoute',
                'ipFilters'=>array('127.0.0.1'),
                    ),
                ),
            ),
)

Upvotes: 1

chen
chen

Reputation: 407

you can try use "CWebLogRoute". it will show you more information.

Try add it under "main.php".

'log' => array(
    'class' => 'CLogRouter',
    'routes' => array(
        array(
            'class' => 'CFileLogRoute',
            'levels' => 'error, warning',
        ),

        array(
            'class'=>'CWebLogRoute',
        ),
    ),
),

Upvotes: 0

Related Questions