Skip to content

Commit

Permalink
Remove build warnings from the profile plugin (#420)
Browse files Browse the repository at this point in the history
Previously, the profile plugin had been causing warnings to appear during building. This change removes those warnings by adding Closure annotations.

@ioeric @sam-mccall
  • Loading branch information
chihuahua authored Aug 25, 2017
1 parent 1c7b8ce commit 68fe042
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
6 changes: 4 additions & 2 deletions tensorboard/plugins/profile/tf_op_profile/tf-op-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
},
_percent: percent,
_updateValue: function(value) {
this.style.background = "linear-gradient(to right, " + flameColor(value) +
" " + percent(value) + ", #ccc " + percent(value) + ")";
const color = flameColor(value);
const length = percent(value);
this.style.background =
"linear-gradient(to right, ${color} ${length}, #ccc ${length})";
},
});
</script>
Expand Down
12 changes: 9 additions & 3 deletions tensorboard/plugins/profile/tf_op_profile/tf-op-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,17 @@
value: null,
notify: true,
},
// Handlers for hover/click events on entries.
// We don't use two-way data binding on _hover and _selected, because
// we get slowdown when they change.
/**
* Handlers for hover/click events on entries.
* We don't use two-way data binding on _hover and _selected, because
* we get slowdown when they change.
* @type {Function}
*/
_onHeaderHover: {
type: Object,
value: function() { return (entry) => this._hover = entry; },
},
/** @type {Function} */
_onHeaderClick: {
type: Object,
value: function() {
Expand Down Expand Up @@ -206,11 +210,13 @@
type: Number,
value: 0,
},
/** @type {Function} */
headerHover: {
type: Object,
value: () => function(entry) {},
notify: true,
},
/** @type {Function} */
headerClick: {
type: Object,
value: () => function(entry) {},
Expand Down
7 changes: 7 additions & 0 deletions tensorboard/plugins/profile/tf_op_profile/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ function rgba(red: number, green: number, blue: number, alpha: number) {
"," + Math.round(blue * 255) + "," + alpha + ")";
}

/**
* Computes a flame color.
* @param {number} fraction
* @param {number=} brightness
* @param {number=} opacity
* @return {string} An RGBA color.
*/
export function flameColor(fraction: number, brightness = 1, opacity = 1) {
if (isNaN(fraction)) return rgba(brightness, brightness, brightness, opacity);
fraction = Math.sqrt(fraction); // Or everything is depressing and red.
Expand Down

0 comments on commit 68fe042

Please sign in to comment.