Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1567)

Unified Diff: Source/devtools/front_end/TimelinePowerGraph.js

Issue 220963002: DevTools: Add energy value under Timeline pie chart (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add to PowerGraph Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/TimelinePowerGraph.js
diff --git a/Source/devtools/front_end/TimelinePowerGraph.js b/Source/devtools/front_end/TimelinePowerGraph.js
index 952011d2a0e6b070291bf6ac41e14fe7d72c53ff..ab0a391c0ab2b26f31a09eb060272db139150ad6 100644
--- a/Source/devtools/front_end/TimelinePowerGraph.js
+++ b/Source/devtools/front_end/TimelinePowerGraph.js
@@ -13,7 +13,11 @@ WebInspector.TimelinePowerGraph = function(delegate, model)
{
WebInspector.CountersGraph.call(this, delegate, model);
- this._counter = this.createCounter(WebInspector.UIString("Power"), WebInspector.UIString("Power: %.2f\u2009watts"), "#d00");
+ var color = "#d00";
+ this._energy = this._currentValuesBar.createChild("span", "memory-counter-value");
+ this._energy.style.color = color;
+ this._counter = this.createCounter(WebInspector.UIString("Power"), WebInspector.UIString("Power: %.2f\u2009watts"), color);
+
WebInspector.powerProfiler.addEventListener(WebInspector.PowerProfiler.EventTypes.PowerEventRecorded, this._onRecordAdded, this);
}
@@ -40,5 +44,36 @@ WebInspector.TimelinePowerGraph.prototype = {
{
},
+ /**
+ * @param {!WebInspector.CountersGraph.CounterUI} counterUI
+ */
+ _drawGraph: function(counterUI)
pfeldman 2014/04/01 14:21:10 You can't override _drawGraph from another file -
+ {
+ WebInspector.CountersGraph.prototype._drawGraph.call(this, counterUI);
+ var counter = this._counter;
+ var values = counter.values;
+
+ if (!values.length)
+ return;
+
+ var energy = 0;
+ var start = counter.minimumIndex;
+ var end = counter.maximumIndex;
+ var times = counter.times;
+
+ for (var i = start + 1; i < end - 1; i++) {
+ energy += (times[i + 1] - times[i]) * values[i];
+ }
+
+ if (start + 1 === end) {
+ energy += (counter.maxTime - counter.minTime) * values[start];
+ } else {
+ energy += (times[start + 1] - counter.minTime) * values[start];
+ energy += (counter.maxTime - times[end - 1]) * values[end - 1];
+ }
+
+ this._energy.textContent = WebInspector.UIString("Energy: %.2f\u2009joules", energy / 1000);
+ },
+
__proto__: WebInspector.CountersGraph.prototype
}
« Source/devtools/front_end/CountersGraph.js ('K') | « Source/devtools/front_end/CountersGraph.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698