Commit 574d1b6b authored by oka's avatar oka Committed by Commit bot

Files App: add more performance metrics for foreground initialization.

FileBrowser.Load.ImportElements:
    Time to initialize the polymer elements.
FileBrowser.Load.InitBackgroundPage:
    Time to initialize the background page.
FileBrowser.Load.InitDocuments:
    Time to initialize the background page and the elements.
FileBrowser.Load.InitSettings:
    Time to restore user settings.
FileBrowser.Load.InitUI:
    Time to initialize all UI after all elements are initialized.

BUG=675536
TEST=manually confirmed on Linux that the above values are exported to chrome://histograms.

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2589693002
Cr-Commit-Position: refs/heads/master@{#439769}
parent aaa61214
...@@ -110100,6 +110100,15 @@ value. ...@@ -110100,6 +110100,15 @@ value.
<suffix name="BackgroundLaunch" <suffix name="BackgroundLaunch"
label="Time from onLaunched event is called to the window is created."/> label="Time from onLaunched event is called to the window is created."/>
<suffix name="BackgroundRestart" label="Time to create a window on restart."/> <suffix name="BackgroundRestart" label="Time to create a window on restart."/>
<suffix name="ImportElements"
label="Time to initialize the polymer elements."/>
<suffix name="InitBackgroundPage"
label="Time to initialize the background page."/>
<suffix name="InitDocuments"
label="Time to initialize the background page and the elements."/>
<suffix name="InitSettings" label="Time to restore user settings."/>
<suffix name="InitUI"
label="Time to initialize all UI after all elements are initialized."/>
<affected-histogram name="FileBrowser.Load"/> <affected-histogram name="FileBrowser.Load"/>
</histogram_suffixes> </histogram_suffixes>
...@@ -10,11 +10,17 @@ window.Polymer.dom = 'shadow'; ...@@ -10,11 +10,17 @@ window.Polymer.dom = 'shadow';
* elements for file manager UI are loaded. * elements for file manager UI are loaded.
*/ */
window.importElementsPromise = new Promise(function(resolve, reject) { window.importElementsPromise = new Promise(function(resolve, reject) {
var startTime = Date.now();
var link = document.createElement('link'); var link = document.createElement('link');
link.rel = 'import'; link.rel = 'import';
link.href = 'foreground/elements/elements_bundle.html'; link.href = 'foreground/elements/elements_bundle.html';
link.setAttribute('async', ''); link.setAttribute('async', '');
link.onload = resolve; link.onload = function() {
chrome.metricsPrivate.recordTime(
'FileBrowser.Load.ImportElements', Date.now() - startTime);
resolve();
};
link.onerror = reject; link.onerror = reject;
document.head.appendChild(link); document.head.appendChild(link);
}); });
...@@ -466,9 +466,13 @@ FileManager.prototype = /** @struct */ { ...@@ -466,9 +466,13 @@ FileManager.prototype = /** @struct */ {
* @private * @private
*/ */
FileManager.prototype.startInitSettings_ = function() { FileManager.prototype.startInitSettings_ = function() {
metrics.startInterval('Load.InitSettings');
this.appStateController_ = new AppStateController(this.dialogType); this.appStateController_ = new AppStateController(this.dialogType);
return new Promise(function(resolve) { return new Promise(function(resolve) {
this.appStateController_.loadInitialViewOptions().then(resolve); this.appStateController_.loadInitialViewOptions().then(function() {
metrics.recordInterval('Load.InitSettings');
resolve();
});
}.bind(this)); }.bind(this));
}; };
...@@ -715,16 +719,20 @@ FileManager.prototype = /** @struct */ { ...@@ -715,16 +719,20 @@ FileManager.prototype = /** @struct */ {
this.dialogDom_ = dialogDom; this.dialogDom_ = dialogDom;
this.document_ = this.dialogDom_.ownerDocument; this.document_ = this.dialogDom_.ownerDocument;
metrics.startInterval('Load.InitDocuments');
return Promise.all([ return Promise.all([
this.initBackgroundPagePromise_, this.initBackgroundPagePromise_,
window.importElementsPromise window.importElementsPromise
]).then(function() { ]).then(function() {
metrics.recordInterval('Load.InitDocuments');
metrics.startInterval('Load.InitUI');
this.initEssentialUI_(); this.initEssentialUI_();
this.initAdditionalUI_(); this.initAdditionalUI_();
return this.initSettingsPromise_; return this.initSettingsPromise_;
}.bind(this)).then(function() { }.bind(this)).then(function() {
this.initFileSystemUI_(); this.initFileSystemUI_();
this.initUIFocus_(); this.initUIFocus_();
metrics.recordInterval('Load.InitUI');
}.bind(this)); }.bind(this));
}; };
...@@ -770,6 +778,7 @@ FileManager.prototype = /** @struct */ { ...@@ -770,6 +778,7 @@ FileManager.prototype = /** @struct */ {
*/ */
FileManager.prototype.startInitBackgroundPage_ = function() { FileManager.prototype.startInitBackgroundPage_ = function() {
return new Promise(function(resolve) { return new Promise(function(resolve) {
metrics.startInterval('Load.InitBackgroundPage');
chrome.runtime.getBackgroundPage(/** @type {function(Window=)} */ ( chrome.runtime.getBackgroundPage(/** @type {function(Window=)} */ (
function(opt_backgroundPage) { function(opt_backgroundPage) {
assert(opt_backgroundPage); assert(opt_backgroundPage);
...@@ -787,6 +796,7 @@ FileManager.prototype = /** @struct */ { ...@@ -787,6 +796,7 @@ FileManager.prototype = /** @struct */ {
this.backgroundPage_.background.mediaScanner; this.backgroundPage_.background.mediaScanner;
this.historyLoader_ = this.historyLoader_ =
this.backgroundPage_.background.historyLoader; this.backgroundPage_.background.historyLoader;
metrics.recordInterval('Load.InitBackgroundPage');
resolve(); resolve();
}.bind(this)); }.bind(this));
}.bind(this))); }.bind(this)));
......
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