Skip to content

Commit

Permalink
MDL-15273 basic read/write perf counter in moodle_database
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jun 18, 2008
1 parent edef70c commit ec22e38
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions admin/cron.php
Expand Up @@ -110,15 +110,15 @@
if (function_exists($cron_function)) {
mtrace("Processing module function $cron_function ...", '');
$pre_dbqueries = null;
$pre_dbqueries = $DB->perf_get_reads();
$pre_dbqueries = $DB->perf_get_queries();
$pre_time = microtime(1);
if ($cron_function()) {
if (!$DB->set_field("modules", "lastcron", $timenow, array("id"=>$mod->id))) {
mtrace("Error: could not update timestamp for $mod->fullname");
}
}
if (isset($pre_dbqueries)) {
mtrace("... used " . ($DB->perf_get_reads() - $pre_dbqueries) . " dbqueries");
mtrace("... used " . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries");
mtrace("... used " . (microtime(1) - $pre_time) . " seconds");
}
/// Reset possible changes by modules to time_limit. MDL-11597
Expand Down Expand Up @@ -171,11 +171,11 @@
$cronfunction = 'report_'.$report.'_cron';
mtrace('Processing cron function for '.$report.'...', '');
$pre_dbqueries = null;
$pre_dbqueries = $DB->perf_get_reads();
$pre_dbqueries = $DB->perf_get_queries();
$pre_time = microtime(true);
$cronfunction();
if (isset($pre_dbqueries)) {
mtrace("... used " . ($DB->perf_get_reads() - $pre_dbqueries) . " dbqueries");
mtrace("... used " . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries");
mtrace("... used " . round(microtime(true) - $pre_time, 2) . " seconds");
}
mtrace('done.');
Expand Down
1 change: 1 addition & 0 deletions lib/dml/moodle_database.php
Expand Up @@ -1403,6 +1403,7 @@ public function rollback_sql() {
return true;
}

/// performance and logging
/**
* Returns number of reads done by this database
* @return int
Expand Down

0 comments on commit ec22e38

Please sign in to comment.