Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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