зеркало из https://github.com/mozilla/gecko-dev.git
Bug 939414 - Dump memory stats for browser-chrome. (r=ted)
This commit is contained in:
Родитель
1e13d8499d
Коммит
7a9dd72104
|
@ -71,8 +71,10 @@ function Tester(aTests, aDumper, aCallback) {
|
|||
this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js", simpleTestScope);
|
||||
this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ChromePowers.js", simpleTestScope);
|
||||
this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/SimpleTest.js", simpleTestScope);
|
||||
this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/MemoryStats.js", simpleTestScope);
|
||||
this._scriptLoader.loadSubScript("chrome://mochikit/content/chrome-harness.js", simpleTestScope);
|
||||
this.SimpleTest = simpleTestScope.SimpleTest;
|
||||
this.MemoryStats = simpleTestScope.MemoryStats;
|
||||
this.Task = Components.utils.import("resource://gre/modules/Task.jsm", null).Task;
|
||||
this.Promise = Components.utils.import("resource://gre/modules/commonjs/sdk/core/promise.js", null).Promise;
|
||||
}
|
||||
|
@ -352,6 +354,14 @@ 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((l) => { this.dumper.dump(l + "\n"); });
|
||||
}
|
||||
|
||||
// Note the test run time
|
||||
let time = Date.now() - this.lastStartTime;
|
||||
this.dumper.dump("INFO TEST-END | " + this.currentTest.path + " | finished in " + time + "ms\n");
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
src="chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/>
|
||||
<script type="text/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/ChromePowers.js"/>
|
||||
<script type="text/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/MemoryStats.js"/>
|
||||
<script type="text/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/TestRunner.js"/>
|
||||
<script type="text/javascript"
|
||||
|
|
|
@ -16,6 +16,7 @@ mochikit.jar:
|
|||
content/tests/SimpleTest/EventUtils.js (tests/SimpleTest/EventUtils.js)
|
||||
content/tests/SimpleTest/ChromeUtils.js (tests/SimpleTest/ChromeUtils.js)
|
||||
content/tests/SimpleTest/LogController.js (tests/SimpleTest/LogController.js)
|
||||
content/tests/SimpleTest/MemoryStats.js (tests/SimpleTest/MemoryStats.js)
|
||||
content/tests/SimpleTest/MozillaLogger.js (../specialpowers/content/MozillaLogger.js)
|
||||
content/tests/SimpleTest/SpecialPowersObserverAPI.js (../specialpowers/content/SpecialPowersObserverAPI.js)
|
||||
content/tests/SimpleTest/specialpowersAPI.js (../specialpowers/content/specialpowersAPI.js)
|
||||
|
|
|
@ -604,6 +604,8 @@ function testListing(metadata, response)
|
|||
),
|
||||
SCRIPT({type: "text/javascript",
|
||||
src: "/tests/SimpleTest/LogController.js"}),
|
||||
SCRIPT({type: "text/javascript",
|
||||
src: "/tests/SimpleTest/MemoryStats.js"}),
|
||||
SCRIPT({type: "text/javascript",
|
||||
src: "/tests/SimpleTest/TestRunner.js"}),
|
||||
SCRIPT({type: "text/javascript",
|
||||
|
|
|
@ -7,6 +7,7 @@ _SIMPLETEST_FILES = LogController.js \
|
|||
SimpleTest.js \
|
||||
test.css \
|
||||
TestRunner.js \
|
||||
MemoryStats.js \
|
||||
setup.js \
|
||||
EventUtils.js \
|
||||
ChromeUtils.js \
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
var MemoryStats = {};
|
||||
|
||||
/**
|
||||
* Statistics that we want to retrieve and display after every test is
|
||||
* done. The keys of this table are intended to be identical to the
|
||||
* relevant attributes of nsIMemoryReporterManager. However, since
|
||||
* nsIMemoryReporterManager doesn't necessarily support all these
|
||||
* statistics in all build configurations, we also use this table to
|
||||
* tell us whether statistics are supported or not.
|
||||
*/
|
||||
var MEM_STAT_UNKNOWN = 0;
|
||||
var MEM_STAT_UNSUPPORTED = 1;
|
||||
var MEM_STAT_SUPPORTED = 2;
|
||||
|
||||
MemoryStats._hasMemoryStatistics = {}
|
||||
MemoryStats._hasMemoryStatistics.vsize = MEM_STAT_UNKNOWN;
|
||||
MemoryStats._hasMemoryStatistics.vsizeMaxContiguous = MEM_STAT_UNKNOWN;
|
||||
MemoryStats._hasMemoryStatistics.residentFast = MEM_STAT_UNKNOWN;
|
||||
MemoryStats._hasMemoryStatistics.heapAllocated = MEM_STAT_UNKNOWN;
|
||||
|
||||
MemoryStats.dump = function (dumpFn) {
|
||||
var mrm;
|
||||
try {
|
||||
mrm = Cc["@mozilla.org/memory-reporter-manager;1"]
|
||||
.getService(Ci.nsIMemoryReporterManager);
|
||||
} catch (e) {
|
||||
mrm = SpecialPowers.Cc["@mozilla.org/memory-reporter-manager;1"]
|
||||
.getService(SpecialPowers.Ci.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) {
|
||||
dumpFn("TEST-INFO | MEMORY STAT " + stat + " after test: " + mrm[stat]);
|
||||
} else if (firstAccess) {
|
||||
dumpFn("TEST-INFO | MEMORY STAT " + stat + " not supported in this build configuration.");
|
||||
}
|
||||
}
|
||||
};
|
|
@ -392,22 +392,6 @@ TestRunner.expectChildProcessCrash = function() {
|
|||
TestRunner._expectingProcessCrash = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Statistics that we want to retrieve and display after every test is
|
||||
* done. The keys of this table are intended to be identical to the
|
||||
* relevant attributes of nsIMemoryReporterManager. However, since
|
||||
* nsIMemoryReporterManager doesn't necessarily support all these
|
||||
* statistics in all build configurations, we also use this table to
|
||||
* tell us whether statistics are supported or not.
|
||||
*/
|
||||
var MEM_STAT_UNKNOWN = 0;
|
||||
var MEM_STAT_UNSUPPORTED = 1;
|
||||
var MEM_STAT_SUPPORTED = 2;
|
||||
TestRunner._hasMemoryStatistics = {}
|
||||
TestRunner._hasMemoryStatistics.vsize = MEM_STAT_UNKNOWN;
|
||||
TestRunner._hasMemoryStatistics.vsizeMaxContiguous = MEM_STAT_UNKNOWN;
|
||||
TestRunner._hasMemoryStatistics.heapAllocated = MEM_STAT_UNKNOWN;
|
||||
|
||||
/**
|
||||
* This stub is called by SimpleTest when a test is finished.
|
||||
**/
|
||||
|
@ -425,33 +409,7 @@ TestRunner.testFinished = function(tests) {
|
|||
TestRunner._lastTestFinished = TestRunner._currentTest;
|
||||
TestRunner._loopIsRestarting = false;
|
||||
|
||||
var mrm;
|
||||
try {
|
||||
mrm = Cc["@mozilla.org/memory-reporter-manager;1"]
|
||||
.getService(Ci.nsIMemoryReporterManager);
|
||||
} catch (e) {
|
||||
mrm = SpecialPowers.Cc["@mozilla.org/memory-reporter-manager;1"]
|
||||
.getService(SpecialPowers.Ci.nsIMemoryReporterManager);
|
||||
}
|
||||
for (stat in TestRunner._hasMemoryStatistics) {
|
||||
var supported = TestRunner._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;
|
||||
}
|
||||
TestRunner._hasMemoryStatistics[stat] = supported;
|
||||
}
|
||||
if (supported == MEM_STAT_SUPPORTED) {
|
||||
TestRunner.log("TEST-INFO | MEMORY STAT " + stat + " after test: " + mrm[stat]);
|
||||
} else if (firstAccess) {
|
||||
TestRunner.log("TEST-INFO | MEMORY STAT " + stat + " not supported in this build configuration.");
|
||||
}
|
||||
}
|
||||
MemoryStats.dump(TestRunner.log);
|
||||
|
||||
function cleanUpCrashDumpFiles() {
|
||||
if (!SpecialPowers.removeExpectedCrashDumpFiles(TestRunner._expectingProcessCrash)) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<head>
|
||||
<!-- This harness does not work locally in Safari -->
|
||||
<script type="text/javascript" src="../MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="SimpleTest/MemoryStats.js"></script>
|
||||
<script type="text/javascript" src="SimpleTest/TestRunner.js"></script>
|
||||
<script type="text/javascript" src="SimpleTest/MozillaLogger.js"></script>
|
||||
<!--<link rel="stylesheet" type="text/css" href="/static/main.css" />-->
|
||||
|
|
Загрузка…
Ссылка в новой задаче