Commit 5e0273ef authored by Penny Leach's avatar Penny Leach
Browse files

better abstraction for the performance stuff

parent 91fac199
......@@ -1514,6 +1514,25 @@ function get_performance_info() {
return $info;
}
function perf_to_log($info) {
if (!get_config('perftolog')) {
return true;
}
if (empty($info)) {
$info = get_performance_info();
}
$logstring = 'PERF: ' . strip_querystring(get_script_path()). ': ';
$logstring .= ' memory_total: '.$info['memory_total'].'B (' . display_size($info['memory_total']).') memory_growth: '.$info['memory_growth'].'B ('.display_size($info['memory_growth']).')';
$logstring .= ' time: '.$info['realtime'].'s';
$logstring .= ' includecount: '.$info['includecount'];
$logstring .= ' dbqueries: '.$info['dbreads'] . ' reads, ' . $info['dbwrites'] . ' writes';
$logstring .= ' ticks: ' . $info['ticks'] . ' user: ' . $info['utime'] . ' sys: ' . $info['stime'] .' cuser: ' . $info['cutime'] . ' csys: ' . $info['cstime'];
$logstring .= ' serverload: ' . $info['serverload'];
log_debug($logstring);
}
/**
* microtime_diff
*
......
......@@ -38,14 +38,7 @@ function smarty_function_mahara_performance_info($params, &$smarty) {
$smarty->assign('perf_memory_growth_display', display_size($info['memory_growth']));
if (get_config('perftolog')) {
$logstring = 'PERF: ' . strip_querystring(get_script_path()). ': ';
$logstring .= ' memory_total: '.$info['memory_total'].'B (' . display_size($info['memory_total']).') memory_growth: '.$info['memory_growth'].'B ('.display_size($info['memory_growth']).')';
$logstring .= ' time: '.$info['realtime'].'s';
$logstring .= ' includecount: '.$info['includecount'];
$logstring .= ' dbqueries: '.$info['dbqueries'];
$logstring .= ' ticks: ' . $info['ticks'] . ' user: ' . $info['utime'] . ' sys: ' . $info['stime'] .' cuser: ' . $info['cutime'] . ' csys: ' . $info['cstime'];
$logstring .= ' serverload: ' . $info['serverload'];
log_debug($logstring);
perf_to_log($info);
}
if (get_config('perftofoot')) {
......
......@@ -482,6 +482,8 @@ function json_headers() {
function json_reply($error, $message) {
json_headers();
echo json_encode(array('error' => $error, 'message' => $message));
log_debug('calling from json_reply');
perf_to_log();
exit;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment