No profile data was found.
@@ -145,6 +153,26 @@ No profile data was found.
height: 100%;
box-sizing: border-box;
}
+ #progress-bar {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ width: 100%;
+ position: absolute;
+ top: 40px;
+ left: 0;
+ font-size: 13px;
+ }
+ #progress-msg {
+ width: 400px;
+ margin-bottom: 5px;
+ }
+ paper-progress {
+ width: 400px;
+ --paper-progress-height: 6px;
+ --paper-progress-active-color: #f3913e;
+ }
@@ -177,6 +205,16 @@ No profile data was found.
type: Array,
observer: '_activeHostsChanged'
},
+ /**
+ * @type {{value: number, msg: string}}
+ *
+ * A number between 0 and 100 denoting the % of progress
+ * for the progress bar and the displayed message.
+ */
+ progress: {
+ type: Object,
+ notify: true,
+ },
selectedDatasetIndex: {
type: Number,
notify: true,
@@ -243,7 +281,7 @@ No profile data was found.
observers: [
'_maybeInitializeDashboard(_isAttached)',
'_maybeUpdateData(_selectedHostName)',
- '_maybeUpdateActiveHosts(_selectedDatasetName, _selectedToolName)'
+ '_maybeUpdateActiveHosts(_selectedDatasetName, _selectedToolName)',
],
attached: function() {
this.set('_isAttached', true);
@@ -251,6 +289,10 @@ No profile data was found.
detached: function() {
this.set('_isAttached', false);
},
+ /** True if the progress is not complete yet (< 100 %). */
+ _isNotComplete: function(progress) {
+ return progress.value < 100;
+ },
_maybeInitializeDashboard: function(isAttached) {
if (this._initialized || !isAttached) {
// Either this dashboard is already initialized ... or we are not yet
@@ -262,7 +304,36 @@ No profile data was found.
const profileTagsURL =
tf_backend.getRouter().pluginRoute('profile', '/tools') +
(tf_backend.getRouter().isDemoMode() ? '.json' : '');
- this._requestManager.request(profileTagsURL).then((runToTool) => {
+ // Reset the progress bar to 0.
+ this.set('progress', {
+ value: 0,
+ msg: ''
+ });
+ let parent = this;
+ let tracker = tf.profile.util.getTracker(this);
+ tf.profile.util.runTask('Loading datasets', 20, () => {
+ console.log('start counting');
+ return parent._requestManager.request(profileTagsURL);
+ }, tracker)
+ .then((runToTool) => {
+ return tf.profile.util.runTask(
+ 'Processing datasets', 70, () => {
+ return new Promise(function(resolve, reject) {
+ parent._processRunToTool(runToTool);
+ return Promise.resolve(null);
+ });
+ }, tracker);
+ })
+ .then(() => {
+ return tf.profile.util.runTask(
+ 'Done', 10, () => {
+ return new Promise(function(resolve, reject) {
+ return Promise.resolve(null);
+ });
+ }, tracker);
+ });
+ },
+ _processRunToTool: function(runToTool) {
var datasets = _.map(runToTool, (tools, run) => ({
name: run,
activeTools: tools,
@@ -275,7 +346,6 @@ No profile data was found.
});
this.set('_dataNotFound', datasets.length === 0);
this.set('_datasets', datasets);
- });
},
// Return the item selected from the list
_getSelected: function(index, li) {
@@ -287,14 +357,16 @@ No profile data was found.
},
_getSelectedDatasetName: function(selectedDatasetIndex, datasets){
if (selectedDatasetIndex == null) return;
- if (datasets && selectedDatasetIndex >= 0 && selectedDatasetIndex < datasets.length) {
+ if (datasets && selectedDatasetIndex >= 0 &&
+ selectedDatasetIndex < datasets.length) {
return datasets[selectedDatasetIndex].name;
}
return '';
},
_getActiveToolsList: function(selectedDatasetIndex, datasets) {
if (selectedDatasetIndex == null) return;
- if (datasets && selectedDatasetIndex >= 0 && selectedDatasetIndex < datasets.length) {
+ if (datasets && selectedDatasetIndex >= 0 &&
+ selectedDatasetIndex < datasets.length) {
this.selectedToolIndex = 0;
return datasets[selectedDatasetIndex].activeTools;
}
@@ -305,7 +377,7 @@ No profile data was found.
var datasetName = this._selectedDatasetName;
var toolName = this._selectedToolName;
if (datasetName == null || toolName == null) return;
- this.toolInScope = "undefined";
+ this._toolInScope = "undefined";
if (toolName.startsWith("trace_viewer")) {
var trace_data_url = tf_backend.addParams(
tf_backend.getRouter().pluginRoute('profile', '/data'),
@@ -325,29 +397,50 @@ No profile data was found.
this._toolInScope = "trace_viewer";
return;
} else {
- this._requestManager.request(tf_backend.addParams(
- tf_backend.getRouter().pluginRoute('profile', '/data'),
- {tag: toolName, host: hostName, run: datasetName})
- ).catch(error => {}
- ).then((data) => {
- if (toolName == "op_profile") {
- this._opProfileData = data;
- this._toolInScope = "op_profile";
- } else if (toolName == "input_pipeline_analyzer") {
- this._inputPipelineData = data;
- this._toolInScope = "input_pipeline_analyzer";
- } else if (toolName == "overview_page") {
- this._overviewPageData = data;
- this._toolInScope = "overview_page";
- } else if (toolName == "memory_viewer") {
- this._memoryViewerData = data;
- this._toolInScope = "memory_viewer";
- } else if (toolName == "google_chart_demo") {
- this._googleChartDemoData = data;
- this._toolInScope = "google_chart_demo";
- }
+ // Reset the progress bar to 0.
+ this.set('progress', {
+ value: 0,
+ msg: ''
});
- return;
+ let parent = this;
+ let tracker = tf.profile.util.getTracker(this);
+ tf.profile.util.runTask('Reading ' + toolName + ' tool data', 20,
+ () => {
+ return parent._requestManager.request(tf_backend.addParams(
+ tf_backend.getRouter().pluginRoute('profile', '/data'),
+ {tag: toolName, host: hostName, run: datasetName}))
+ }, tracker)
+ .catch(error => {})
+ .then((data) => {
+ return tf.profile.util.runTask('Done', 80, () => {
+ parent._updateToolData(toolName, data);
+ }, tracker);
+ });
+ }
+ },
+
+ _updateToolData: function(toolName, data) {
+ switch(toolName) {
+ case "op_profile":
+ this._opProfileData = data;
+ this._toolInScope = "op_profile";
+ break;
+ case "input_pipeline_analyzer":
+ this._inputPipelineData = data;
+ this._toolInScope = "input_pipeline_analyzer";
+ break;
+ case "overview_page":
+ this._overviewPageData = data;
+ this._toolInScope = "overview_page";
+ break;
+ case "memory_viewer":
+ this._memoryViewerData = data;
+ this._toolInScope = "memory_viewer";
+ break;
+ case "google_chart_demo":
+ this._googleChartDemoData = data;
+ this._toolInScope = "google_chart_demo";
+ break;
}
},
_maybeUpdateActiveHosts: function(datasetName, toolName) {
@@ -369,8 +462,9 @@ No profile data was found.
}
},
_activeToolsChanged: function(oldActiveTools, newActiveTools) {
- // Same tool can have differernt index in different runs, therefore we force a change of
- // 'selectedToolIndex', to make sure the label of the dropdown-menu is synced.
+ // Same tool can have differernt index in different runs, therefore we
+ // force a change of 'selectedToolIndex', to make sure the label of the
+ // dropdown-menu is synced.
if (this._activeToolsList) {
this.async(function() {
this.set('selectedToolIndex', -1);