Bug 1150646 - Ensure that memory stats show up in treeherder logs. r=chmanchester
authorTom Tromey <tromey@mozilla.com>
Fri, 03 Apr 2015 11:19:00 -0400
changeset 237760 e7b56aed5164e57be345cbc74902c15d40efb14d
parent 237759 2bb03bbdbd79e5419ede588103e7e123c7bf9f5f
child 237761 b2cc5a85ed5d252668397889c82e8540d67d37a0
push id28549
push userryanvm@gmail.com
push dateTue, 07 Apr 2015 01:19:17 +0000
treeherdermozilla-central@335f1295e99b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1150646
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1150646 - Ensure that memory stats show up in treeherder logs. r=chmanchester
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
@@ -508,18 +508,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,