Skip to content

Commit

Permalink
Merge branch 'MDL-57427_m31' of https://github.com/jrchamp/moodle int…
Browse files Browse the repository at this point in the history
…o MOODLE_31_STABLE
  • Loading branch information
danpoltawski committed Jan 9, 2017
2 parents d05d5cd + e3d53b9 commit 1910eaf
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cache/classes/loaders.php
Expand Up @@ -213,7 +213,7 @@ public function __construct(cache_definition $definition, cache_store $store, $l
$this->definition = $definition;
$this->store = $store;
$this->storetype = get_class($store);
$this->perfdebug = !empty($CFG->perfdebug);
$this->perfdebug = (!empty($CFG->perfdebug) and $CFG->perfdebug > 7);
if ($loader instanceof cache_loader) {
$this->loader = $loader;
// Mark the loader as a sub (chained) loader.
Expand Down
53 changes: 53 additions & 0 deletions cache/tests/cache_test.php
Expand Up @@ -2170,4 +2170,57 @@ public function test_performance_debug() {
$this->assertEquals(0, $endstats[$requestid]['stores']['cachestore_static']['sets'] -
$startstats[$requestid]['stores']['cachestore_static']['sets']);
}

public function test_performance_debug_off() {
global $CFG;
$this->resetAfterTest(true);
$CFG->perfdebug = 7;

$instance = cache_config_testing::instance();
$applicationid = 'phpunit/applicationperfoff';
$instance->phpunit_add_definition($applicationid, array(
'mode' => cache_store::MODE_APPLICATION,
'component' => 'phpunit',
'area' => 'applicationperfoff'
));
$sessionid = 'phpunit/sessionperfoff';
$instance->phpunit_add_definition($sessionid, array(
'mode' => cache_store::MODE_SESSION,
'component' => 'phpunit',
'area' => 'sessionperfoff'
));
$requestid = 'phpunit/requestperfoff';
$instance->phpunit_add_definition($requestid, array(
'mode' => cache_store::MODE_REQUEST,
'component' => 'phpunit',
'area' => 'requestperfoff'
));

$application = cache::make('phpunit', 'applicationperfoff');
$session = cache::make('phpunit', 'sessionperfoff');
$request = cache::make('phpunit', 'requestperfoff');

// Check that no stats are recorded for these definitions yet.
$stats = cache_helper::get_stats();
$this->assertArrayNotHasKey($applicationid, $stats);
$this->assertArrayNotHasKey($sessionid, $stats);
$this->assertArrayNotHasKey($requestid, $stats);

// Trigger cache misses, cache sets and cache hits.
$this->assertFalse($application->get('missMe'));
$this->assertTrue($application->set('setMe', 1));
$this->assertEquals(1, $application->get('setMe'));
$this->assertFalse($session->get('missMe'));
$this->assertTrue($session->set('setMe', 3));
$this->assertEquals(3, $session->get('setMe'));
$this->assertFalse($request->get('missMe'));
$this->assertTrue($request->set('setMe', 4));
$this->assertEquals(4, $request->get('setMe'));

// Check that no stats are being recorded for these definitions.
$endstats = cache_helper::get_stats();
$this->assertArrayNotHasKey($applicationid, $endstats);
$this->assertArrayNotHasKey($sessionid, $endstats);
$this->assertArrayNotHasKey($requestid, $endstats);
}
}

0 comments on commit 1910eaf

Please sign in to comment.