Bug 403835: Force a GC/CC between each pageload. r=alice sr=rob campbell

This commit is contained in:
jonas@sicking.cc 2007-11-20 14:56:20 -08:00
Родитель 47300cb06e
Коммит 0eb6c848e8
3 изменённых файлов: 43 добавлений и 1 удалений

Просмотреть файл

@ -60,6 +60,8 @@ var noisy = false;
var timeout = -1;
var timeoutEvent = -1;
var running = false;
var forceCC = true;
var useCCApi = false;
var content;
@ -93,8 +95,17 @@ function plInit() {
if (args.filter) pageFilterRegexp = new RegExp(args.filter);
if (args.noisy) noisy = true;
if (args.timeout) timeout = parseInt(args.timeout);
forceCC = !args.noForceCC;
doRenderTest = args.doRender;
if (forceCC) {
if (window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.garbageCollect) {
useCCApi = true;
}
}
gIOS = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
if (args.offline)
@ -221,6 +232,20 @@ function plNextPage() {
if (pageIndex < pages.length-1) {
pageIndex++;
if (forceCC) {
var tccstart = new Date();
if (useCCApi) {
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.garbageCollect();
}
else {
Components.utils.forceGC();
}
var tccend = new Date();
report.recordCCTime(tccend - tccstart);
}
setTimeout(plLoadPage, 250);
} else {
plStop(false);

Просмотреть файл

@ -45,6 +45,8 @@ function Report(pages) {
for (var i = 0; i < this.timeVals.length; ++i) {
this.timeVals[i] = new Array();
}
this.totalCCTime = 0;
this.showTotalCCTime = false;
}
// given an array of strings, finds the longest common prefix
@ -211,6 +213,9 @@ Report.prototype.getReport = function(format) {
this.timeVals[i] +
"\n";
}
if (this.showTotalCCTime) {
report += "Cycle collection: " + this.totalCCTime + "\n"
}
report += "============================================================\n";
} else if (format == "tinderbox") {
report = "__start_tp_report\n";
@ -230,6 +235,11 @@ Report.prototype.getReport = function(format) {
"\n";
}
report += "__end_tp_report\n";
if (this.showTotalCCTime) {
report += "__start_cc_report\n";
report += "_x_x_mozilla_cycle_collect," + this.totalCCTime + "\n";
report += "__end_cc_report\n";
}
} else {
report = "Unknown report format";
}
@ -240,3 +250,8 @@ Report.prototype.getReport = function(format) {
Report.prototype.recordTime = function(pageIndex, ms) {
this.timeVals[pageIndex].push(ms);
}
Report.prototype.recordCCTime = function(ms) {
this.totalCCTime += ms;
this.showTotalCCTime = true;
}

Просмотреть файл

@ -91,6 +91,7 @@ PageLoaderCmdLineHandler.prototype =
args.offline = cmdLine.handleFlag("tpoffline", false);
args.noisy = cmdLine.handleFlag("tpnoisy", false);
args.timeout = cmdLine.handleFlagWithParam("tptimeout", false);
args.noForceCC = cmdLine.handleFlag("tpnoforcecc", false);
}
catch (e) {
return;
@ -119,7 +120,8 @@ PageLoaderCmdLineHandler.prototype =
" -tpheight height Height of window\n" +
" -tpoffline Force offline mode\n" +
" -tpnoisy Dump the name of the last loaded page to console\n" +
" -tptimeout Max amount of time given for a page to load, quit if exceeded\n"
" -tptimeout Max amount of time given for a page to load, quit if exceeded\n" +
" -tpnoforcecc Don't force cycle collection between each pageload\n"
};