Difference between #1 and #2 of
Profiling user requests

Changes

Title unchanged

Profiling user requests

Category unchanged

Tutorials

Yii version unchanged

Tags unchanged

profiling, optimization

Content changed

[...]
public static function starter(CEvent $event) {
self::$start = microtime(true);
}

    public static function bytesToKb($bytes) {
 
        return $bytes * 1024;
 
    }
 
 
    public static function bytesToMb($bytes) {
 
        return self::bytesToKb($bytes) * 1024;
 
    }
 
 
public static function ender(CEvent $event) { $memory = floatval(memory_get_usage(true)); $peak = floatval(memory_get_peak_usage(true)); $error = Yii::app()->getErrorHandler()->error; $param = array( 'request_memory_kb' => Hselperf::bytesToKb($memory), 'request_memory_mb' => Hselperf::bytesToMb($memory), 'request_memory_peak_kb' => Hselperf::bytesToKb($peak), 'request_memory_peak_mb' => Hselperf::bytesToMb($peak), 'request_url' => Yii::app()->request->requestUri, 'request_type' => Yii::app()->request->requestType, 'request_errors' => $error, 'user_status' => !Yii::app()->user->isGuest ? 'Guest' : Yii::app()->user->id, 'user_ip' => !Yii::app()->request->userHostAddress, 'date' => time(), 'time_taken' => microtime(true) - self::$start             //or you can minus the current microtime from the constant YII_BEGIN_TIME
 
);
}

}

```
[...]
1 0
3 followers
Viewed: 9 580 times
Version: 1.1
Category: Tutorials
Written by: M0ka
Last updated by: M0ka
Created on: May 19, 2014
Last updated: 10 years ago
Update Article

Revisions

View all history