Bug 1320671 - Add transferred size to the network performance view. r? draft
authorIan Moody <moz-ian@perix.co.uk>
Fri, 16 Dec 2016 15:56:46 +0000
changeset 450463 f9049332593c85f4ce0212bad5f7e75f764a50aa
parent 450144 63b447888a6469b9f6ae8f76ac5f0d7c6ea239da
child 450464 f266771d946505c27bf76218d803ef8cbf6bab36
push id38860
push usermoz-ian@perix.co.uk
push dateFri, 16 Dec 2016 17:26:05 +0000
bugs1320671
milestone53.0a1
Bug 1320671 - Add transferred size to the network performance view. r? MozReview-Commit-ID: E6SdNAzw09F
devtools/client/locales/en-US/netmonitor.properties
devtools/client/netmonitor/performance-statistics-view.js
--- a/devtools/client/locales/en-US/netmonitor.properties
+++ b/devtools/client/locales/en-US/netmonitor.properties
@@ -232,16 +232,20 @@ charts.cacheEnabled=Primed cache
 # LOCALIZATION NOTE (charts.cacheDisabled): This is the label displayed
 # in the performance analysis view for "cache disabled" charts.
 charts.cacheDisabled=Empty cache
 
 # LOCALIZATION NOTE (charts.totalSize): This is the label displayed
 # in the performance analysis view for total requests size, in kilobytes.
 charts.totalSize=Size: %S KB
 
+# LOCALIZATION NOTE (charts.totalTransferredSize): This is the label displayed
+# in the performance analysis view for total transferred requests size, in kilobytes.
+charts.totalTransferredSize=Transferred size: %S KB
+
 # LOCALIZATION NOTE (charts.totalSeconds): Semi-colon list of plural forms.
 # See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
 # This is the label displayed in the performance analysis view for the
 # total requests time, in seconds.
 charts.totalSeconds=Time: #1 second;Time: #1 seconds
 
 # LOCALIZATION NOTE (charts.totalCached): This is the label displayed
 # in the performance analysis view for total cached responses.
--- a/devtools/client/netmonitor/performance-statistics-view.js
+++ b/devtools/client/netmonitor/performance-statistics-view.js
@@ -92,26 +92,34 @@ PerformanceStatisticsView.prototype = {
    * Common stringifier predicates used for items and totals in both the
    * "primed" and "empty" cache charts.
    */
   _commonChartStrings: {
     size: value => {
       let string = L10N.numberWithDecimals(value / 1024, CONTENT_SIZE_DECIMALS);
       return L10N.getFormatStr("charts.sizeKB", string);
     },
+    transferredSize: value => {
+      let string = L10N.numberWithDecimals(value / 1024, CONTENT_SIZE_DECIMALS);
+      return L10N.getFormatStr("charts.sizeKB", string);
+    },
     time: value => {
       let string = L10N.numberWithDecimals(value / 1000, REQUEST_TIME_DECIMALS);
       return L10N.getFormatStr("charts.totalS", string);
     }
   },
   _commonChartTotals: {
     size: total => {
       let string = L10N.numberWithDecimals(total / 1024, CONTENT_SIZE_DECIMALS);
       return L10N.getFormatStr("charts.totalSize", string);
     },
+    transferredSize: total => {
+      let string = L10N.numberWithDecimals(total / 1024, CONTENT_SIZE_DECIMALS);
+      return L10N.getFormatStr("charts.totalTransferredSize", string);
+    },
     time: total => {
       let seconds = total / 1000;
       let string = L10N.numberWithDecimals(seconds, REQUEST_TIME_DECIMALS);
       return PluralForm.get(seconds,
         L10N.getStr("charts.totalSeconds")).replace("#1", string);
     },
     cached: total => {
       return L10N.getFormatStr("charts.totalCached", total);
@@ -168,16 +176,17 @@ PerformanceStatisticsView.prototype = {
   _sanitizeChartDataSource: function (items, emptyCache) {
     let data = [
       "html", "css", "js", "xhr", "fonts", "images", "media", "flash", "ws", "other"
     ].map(e => ({
       cached: 0,
       count: 0,
       label: e,
       size: 0,
+      transferredSize: 0,
       time: 0
     }));
 
     for (let requestItem of items) {
       let details = requestItem;
       let type;
 
       if (Filters.html(details)) {
@@ -211,16 +220,17 @@ PerformanceStatisticsView.prototype = {
       } else {
         // "other"
         type = 9;
       }
 
       if (emptyCache || !responseIsFresh(details)) {
         data[type].time += details.totalTime || 0;
         data[type].size += details.contentSize || 0;
+        data[type].transferredSize += details.transferredSize || 0;
       } else {
         data[type].cached++;
       }
       data[type].count++;
     }
 
     return data.filter(e => e.count > 0);
   },