Bug 1150646 - Ensure that memory stats show up in treeherder logs. r=chmanchester, a=test-only
authorTom Tromey <tromey@mozilla.com>
Fri, 03 Apr 2015 11:19:00 -0400
changeset 258311 a1d7b2cdd950
parent 258310 f208b7bb88ae
child 258312 a72d76b284ea
push id4643
push userryanvm@gmail.com
push date2015-04-07 14:24 +0000
treeherdermozilla-beta@0c29ab096b90 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester, test-only
bugs1150646
milestone38.0
Bug 1150646 - Ensure that memory stats show up in treeherder logs. r=chmanchester, a=test-only
testing/mochitest/browser-test.js
testing/mochitest/tests/SimpleTest/MemoryStats.js
testing/mochitest/tests/SimpleTest/TestRunner.js
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -457,18 +457,17 @@ Tester.prototype = {
         }
       }
 
       // Dump memory stats for main thread.
       if (Cc["@mozilla.org/xre/runtime;1"]
           .getService(Ci.nsIXULRuntime)
           .processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT)
       {
-        this.MemoryStats.dump(this.dumper.structuredLogger,
-                              this.currentTestIndex,
+        this.MemoryStats.dump(this.currentTestIndex,
                               this.currentTest.path,
                               gConfig.dumpOutputDirectory,
                               gConfig.dumpAboutMemoryAfterTest,
                               gConfig.dumpDMDAfterTest);
       }
 
       // Note the test run time
       let time = Date.now() - this.lastStartTime;
--- a/testing/mochitest/tests/SimpleTest/MemoryStats.js
+++ b/testing/mochitest/tests/SimpleTest/MemoryStats.js
@@ -48,65 +48,70 @@ MemoryStats._nsIFile = function (pathnam
 }
 
 MemoryStats.constructPathname = function (directory, basename) {
     var d = MemoryStats._nsIFile(directory);
     d.append(basename);
     return d.path;
 }
 
-MemoryStats.dump = function (logger,
-                             testNumber,
+MemoryStats.dump = function (testNumber,
                              testURL,
                              dumpOutputDirectory,
                              dumpAboutMemory,
                              dumpDMD) {
+    // Use dump because treeherder uses --quiet, which drops 'info'
+    // from the structured logger.
+    var info = function(message) {
+        dump(message + "\n");
+    };
+
     var mrm = MemoryStats._getService("@mozilla.org/memory-reporter-manager;1",
                                       "nsIMemoryReporterManager");
     for (var stat in MemoryStats._hasMemoryStatistics) {
         var supported = MemoryStats._hasMemoryStatistics[stat];
         var firstAccess = false;
         if (supported == MEM_STAT_UNKNOWN) {
             firstAccess = true;
             try {
                 var value = mrm[stat];
                 supported = MEM_STAT_SUPPORTED;
             } catch (e) {
                 supported = MEM_STAT_UNSUPPORTED;
             }
             MemoryStats._hasMemoryStatistics[stat] = supported;
         }
         if (supported == MEM_STAT_SUPPORTED) {
-            logger.info("MEMORY STAT " + stat + " after test: " + mrm[stat]);
+            info("MEMORY STAT " + stat + " after test: " + mrm[stat]);
         } else if (firstAccess) {
-            logger.info("MEMORY STAT " + stat + " not supported in this build configuration.");
+            info("MEMORY STAT " + stat + " not supported in this build configuration.");
         }
     }
 
     if (dumpAboutMemory) {
         var basename = "about-memory-" + testNumber + ".json.gz";
         var dumpfile = MemoryStats.constructPathname(dumpOutputDirectory,
                                                      basename);
-        logger.info(testURL + " | MEMDUMP-START " + dumpfile);
+        info(testURL + " | MEMDUMP-START " + dumpfile);
         var md = MemoryStats._getService("@mozilla.org/memory-info-dumper;1",
                                          "nsIMemoryInfoDumper");
         md.dumpMemoryReportsToNamedFile(dumpfile, function () {
-            logger.info("TEST-INFO | " + testURL + " | MEMDUMP-END");
+            info("TEST-INFO | " + testURL + " | MEMDUMP-END");
         }, null, /* anonymize = */ false);
     }
 
     // This is the old, deprecated function.
     if (dumpDMD && typeof(DMDReportAndDump) != undefined) {
         var basename = "dmd-" + testNumber + "-deprecated.txt";
         var dumpfile = MemoryStats.constructPathname(dumpOutputDirectory,
                                                      basename);
-        logger.info(testURL + " | DMD-DUMP-deprecated " + dumpfile);
+        info(testURL + " | DMD-DUMP-deprecated " + dumpfile);
         DMDReportAndDump(dumpfile);
     }
 
     if (dumpDMD && typeof(DMDAnalyzeReports) != undefined) {
         var basename = "dmd-" + testNumber + ".txt";
         var dumpfile = MemoryStats.constructPathname(dumpOutputDirectory,
                                                      basename);
-        logger.info(testURL + " | DMD-DUMP " + dumpfile);
+        info(testURL + " | DMD-DUMP " + dumpfile);
         DMDAnalyzeReports(dumpfile);
     }
 };
--- a/testing/mochitest/tests/SimpleTest/TestRunner.js
+++ b/testing/mochitest/tests/SimpleTest/TestRunner.js
@@ -682,17 +682,17 @@ TestRunner.testFinished = function(tests
         TestRunner.updateUI([{ result: false }]);
         return;
     }
     TestRunner._lastTestFinished = TestRunner._currentTest;
     TestRunner._loopIsRestarting = false;
 
     // TODO : replace this by a function that returns the mem data as an object
     // that's dumped later with the test_end message
-    MemoryStats.dump(TestRunner.structuredLogger, TestRunner._currentTest,
+    MemoryStats.dump(TestRunner._currentTest,
                      TestRunner.currentTestURL,
                      TestRunner.dumpOutputDirectory,
                      TestRunner.dumpAboutMemoryAfterTest,
                      TestRunner.dumpDMDAfterTest);
 
     function cleanUpCrashDumpFiles() {
         if (!SpecialPowers.removeExpectedCrashDumpFiles(TestRunner._expectingProcessCrash)) {
             TestRunner.structuredLogger.testEnd(TestRunner.currentTestURL,