MDL-48595 logstore_standard: Fixing unit tests comparing performance

Adding also an extra userid checking as databases
may include userid = 0 records.
This commit is contained in:
David Monllao 2015-03-12 13:52:17 +08:00
parent ce1be0e738
commit 5803e36cc5
2 changed files with 13 additions and 6 deletions

View File

@ -261,13 +261,16 @@ class logstore_standard_store_testcase extends advanced_testcase {
// Look for non-linear memory usage for the iterator version.
$mem = memory_get_usage();
$events = $store->get_events_select('', array(), '', 0, 0);
$delta1 = memory_get_usage() - $mem;
$events = $store->get_events_select_iterator('', array(), '', 0, 0);
$delta2 = memory_get_usage() - $mem;
$this->assertInstanceOf('\Traversable', $events);
$events->close();
$arraymemusage = memory_get_usage() - $mem;
$this->assertLessThan($delta1 / 10, $delta2);
$mem = memory_get_usage();
$eventsit = $store->get_events_select_iterator('', array(), '', 0, 0);
$eventsit->close();
$itmemusage = memory_get_usage() - $mem;
$this->assertInstanceOf('\Traversable', $eventsit);
$this->assertLessThan($arraymemusage / 10, $itmemusage);
set_config('enabled_stores', '', 'tool_log');
get_log_manager(true);

View File

@ -127,6 +127,10 @@ class report_log_table_log extends table_sql {
protected function get_user_fullname($userid) {
global $DB;
if (empty($userid)) {
return false;
}
if (!empty($this->userfullnames[$userid])) {
return $this->userfullnames[$userid];
}