[go: nahoru, domu]

Skip to content

Commit

Permalink
core: refactor check for clearing cache (#9896)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored and paulirish committed Oct 30, 2019
1 parent f0d7ceb commit 6e5fc87
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lighthouse-core/gather/gather-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,12 @@ class GatherRunner {
}

/**
* Returns whether this pass should be considered to be measuring performance.
* Returns whether this pass should clear the caches.
* Only if it is a performance run and the settings don't disable it.
* @param {LH.Gatherer.PassContext} passContext
* @return {boolean}
*/
static isPerfPass(passContext) {
static shouldClearCaches(passContext) {
const {settings, passConfig} = passContext;
return !settings.disableStorageReset && passConfig.recordTrace && passConfig.useThrottling;
}
Expand Down Expand Up @@ -631,8 +632,9 @@ class GatherRunner {
// Go to about:blank, set up, and run `beforePass()` on gatherers.
await GatherRunner.loadBlank(driver, passConfig.blankPage);
await GatherRunner.setupPassNetwork(passContext);
const isPerfPass = GatherRunner.isPerfPass(passContext);
if (isPerfPass) await driver.cleanBrowserCaches(); // Clear disk & memory cache if it's a perf run
if (GatherRunner.shouldClearCaches(passContext)) {
await driver.cleanBrowserCaches(); // Clear disk & memory cache if it's a perf run
}
await GatherRunner.beforePass(passContext, gathererResults);

// Navigate, start recording, and run `pass()` on gatherers.
Expand Down

0 comments on commit 6e5fc87

Please sign in to comment.