From: hickert Date: Mon, 2 Aug 2010 11:21:23 +0000 (+0000) Subject: Added render time to stats table X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8472991587617cac1e78e4d5570b01eeddc42dbc;p=gosa.git Added render time to stats table git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19340 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/html/main.php b/gosa-core/html/main.php index 4be9b3944..fe82c2cfe 100644 --- a/gosa-core/html/main.php +++ b/gosa-core/html/main.php @@ -23,6 +23,9 @@ /* Save start time */ $start = microtime(); +// Will be used in the "stats" plugin later, to be able calculate the elapsed render time. +$overallRenderTimer = microtime(TRUE); + /* Basic setup, remove eventually registered sessions */ require_once ("../include/php_setup.inc"); require_once ("functions.inc"); diff --git a/gosa-core/include/class_stats.inc b/gosa-core/include/class_stats.inc index a043c4dc0..dc2f00b3a 100644 --- a/gosa-core/include/class_stats.inc +++ b/gosa-core/include/class_stats.inc @@ -43,6 +43,7 @@ class stats TIMESTAMP INTEGER, MTIMESTAMP REAL, DURATION REAL, + RENDER_TIME REAL, AMOUNT INTEGER, MEMORY_USAGE INTEGER, CPU_LOAD FLOAT, @@ -60,6 +61,19 @@ class stats { global $config; global $clicks; + global $overallRenderTimer; + + if(!isset($overallRenderTimer) || empty($overallRenderTimer)){ + $renderTime = 0; + }else{ + $renderTime = microtime(TRUE) - $overallRenderTimer; + + // Now set the overallRenderTimer to the current timestamp - else + // we will not be able to sum up the render time in a single SQL statement. + $overallRenderTimer = microtime(TRUE); + + } + $type = sqlite_escape_string($type); $plugin = sqlite_escape_string($plugin); $action = sqlite_escape_string($action); @@ -68,6 +82,7 @@ class stats $uuid = $config->getGOsaUUID(); $amount = sqlite_escape_string($amount); $duration = sqlite_escape_string($duration); + $renderTime = sqlite_escape_string($renderTime); $info = sqlite_escape_string($info); $clicks = sqlite_escape_string($clicks); $memory_usage = sqlite_escape_string(stats::get_memory_usage()); @@ -83,10 +98,12 @@ class stats $TABLE_NAME = 'stats'; $query = " INSERT INTO {$TABLE_NAME} - (ACTID, TYPE, PLUGIN, CATEGORY, ACTION, UUID, MTIMESTAMP, TIMESTAMP, AMOUNT, DURATION, MEMORY_USAGE, CPU_LOAD, INFO) + (ACTID, TYPE, PLUGIN, CATEGORY, ACTION, UUID, MTIMESTAMP, TIMESTAMP, + AMOUNT, DURATION, RENDER_TIME, MEMORY_USAGE, CPU_LOAD, INFO) VALUES ('{$clicks}','{$type}','{$plugin}','{$category}','{$action}','{$uuid}', - '{$mtimestamp}','{$timestamp}','{$amount}','{$duration}','{$memory_usage}','{$cpu_load}','{$info}')"; + '{$mtimestamp}','{$timestamp}','{$amount}','{$duration}','{$renderTime}', + '{$memory_usage}','{$cpu_load}','{$info}')"; sqlite_query($query, $res); }