mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 672731 - Add UNITS_COUNT_CUMULATIVE to nsIMemoryReporter. r=njn
This commit is contained in:
parent
071b50617b
commit
3e07692ce3
@ -48,11 +48,12 @@ var gVerbose = (location.href.split(/[\?,]/).indexOf("verbose") !== -1);
|
||||
|
||||
var gAddedObserver = false;
|
||||
|
||||
const KIND_NONHEAP = Ci.nsIMemoryReporter.KIND_NONHEAP;
|
||||
const KIND_HEAP = Ci.nsIMemoryReporter.KIND_HEAP;
|
||||
const KIND_OTHER = Ci.nsIMemoryReporter.KIND_OTHER;
|
||||
const UNITS_BYTES = Ci.nsIMemoryReporter.UNITS_BYTES;
|
||||
const UNITS_COUNT = Ci.nsIMemoryReporter.UNITS_COUNT;
|
||||
const KIND_NONHEAP = Ci.nsIMemoryReporter.KIND_NONHEAP;
|
||||
const KIND_HEAP = Ci.nsIMemoryReporter.KIND_HEAP;
|
||||
const KIND_OTHER = Ci.nsIMemoryReporter.KIND_OTHER;
|
||||
const UNITS_BYTES = Ci.nsIMemoryReporter.UNITS_BYTES;
|
||||
const UNITS_COUNT = Ci.nsIMemoryReporter.UNITS_COUNT;
|
||||
const UNITS_COUNT_CUMULATIVE = Ci.nsIMemoryReporter.UNITS_COUNT_CUMULATIVE;
|
||||
const UNITS_PERCENTAGE = Ci.nsIMemoryReporter.UNITS_PERCENTAGE;
|
||||
|
||||
const kUnknown = -1; // used for _amount if a memory reporter failed
|
||||
@ -534,10 +535,14 @@ function genProcessText(aProcess, aReporters)
|
||||
function formatReporterAmount(aReporter)
|
||||
{
|
||||
switch(aReporter._units) {
|
||||
case UNITS_BYTES: return formatBytes(aReporter._amount);
|
||||
case UNITS_COUNT: return formatInt(aReporter._amount);
|
||||
case UNITS_PERCENTAGE: return formatPercentage(aReporter._amount);
|
||||
default: return "(???)"
|
||||
case UNITS_BYTES:
|
||||
return formatBytes(aReporter._amount);
|
||||
case UNITS_COUNT:
|
||||
case UNITS_COUNT_CUMULATIVE:
|
||||
return formatInt(aReporter._amount);
|
||||
case UNITS_PERCENTAGE:
|
||||
return formatPercentage(aReporter._amount);
|
||||
default: return "(???)"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
// Remove all the real reporters and multi-reporters; save them to
|
||||
// restore at the end.
|
||||
var e = mgr.enumerateReporters();
|
||||
var e = mgr.enumerateReporters();
|
||||
var realReporters = [];
|
||||
var dummy = 0;
|
||||
while (e.hasMoreElements()) {
|
||||
@ -31,7 +31,7 @@
|
||||
mgr.unregisterReporter(r);
|
||||
realReporters.push(r);
|
||||
}
|
||||
e = mgr.enumerateMultiReporters();
|
||||
e = mgr.enumerateMultiReporters();
|
||||
var realMultiReporters = [];
|
||||
var dummy = 0;
|
||||
while (e.hasMoreElements()) {
|
||||
@ -51,9 +51,10 @@
|
||||
const HEAP = Ci.nsIMemoryReporter.KIND_HEAP;
|
||||
const OTHER = Ci.nsIMemoryReporter.KIND_OTHER;
|
||||
|
||||
const BYTES = Ci.nsIMemoryReporter.UNITS_BYTES;
|
||||
const COUNT = Ci.nsIMemoryReporter.UNITS_COUNT;
|
||||
const PERCENTAGE = Ci.nsIMemoryReporter.UNITS_PERCENTAGE;
|
||||
const BYTES = Ci.nsIMemoryReporter.UNITS_BYTES;
|
||||
const COUNT = Ci.nsIMemoryReporter.UNITS_COUNT;
|
||||
const COUNT_CUMULATIVE = Ci.nsIMemoryReporter.UNITS_COUNT_CUMULATIVE;
|
||||
const PERCENTAGE = Ci.nsIMemoryReporter.UNITS_PERCENTAGE;
|
||||
|
||||
function f2(aProcess, aPath, aKind, aUnits, aAmount) {
|
||||
return {
|
||||
@ -84,7 +85,7 @@
|
||||
f("", "explicit/g/a", HEAP, 6 * MB),
|
||||
f("", "explicit/g/b", HEAP, 5 * MB),
|
||||
f("", "other1", OTHER, 111 * MB),
|
||||
f2("", "other4", OTHER, COUNT, 888),
|
||||
f2("", "other4", OTHER, COUNT_CUMULATIVE, 888),
|
||||
f2("", "unknown-unit", OTHER, /*bogus unit*/999, 999)
|
||||
];
|
||||
var fakeMultiReporters = [
|
||||
|
@ -238,8 +238,11 @@ TelemetryPing.prototype = {
|
||||
val = Math.floor(mr.amount / 1024);
|
||||
}
|
||||
else if (mr.units == Ci.nsIMemoryReporter.UNITS_COUNT) {
|
||||
// If the reporter gives us a count, we'll report the difference in its
|
||||
// value between now and our previous ping.
|
||||
val = mr.amount;
|
||||
}
|
||||
else if (mr.units == Ci.nsIMemoryReporter.UNITS_COUNT_CUMULATIVE) {
|
||||
// If the reporter gives us a cumulative count, we'll report the
|
||||
// difference in its value between now and our previous ping.
|
||||
|
||||
// Read mr.amount just once so our arithmetic is consistent.
|
||||
let curVal = mr.amount;
|
||||
|
@ -131,7 +131,7 @@ interface nsIMemoryReporter : nsISupports
|
||||
readonly attribute PRInt32 kind;
|
||||
|
||||
/*
|
||||
* The amount reported by a memory reporter may have one of the following
|
||||
* The amount reported by a memory reporter must have one of the following
|
||||
* units, but you may of course add new units as necessary:
|
||||
*
|
||||
* - BYTES: The amount contains a number of bytes.
|
||||
@ -141,6 +141,14 @@ interface nsIMemoryReporter : nsISupports
|
||||
* reporter reporting the number of page faults since startup should have
|
||||
* units UNITS_COUNT.
|
||||
*
|
||||
* - COUNT_CUMULATIVE: The amount contains the number of times some event
|
||||
* has occurred since the application started up. For instance, the
|
||||
* number of times the user has opened a new tab would have units
|
||||
* COUNT_CUMULATIVE.
|
||||
*
|
||||
* The amount returned by a reporter with units COUNT_CUMULATIVE must
|
||||
* never decrease over the lifetime of the application.
|
||||
*
|
||||
* - PERCENTAGE: The amount contains a fraction that should be expressed as
|
||||
* a percentage. NOTE! The |amount| field should be given a value 100x
|
||||
* the actual percentage; this number will be divided by 100 when shown.
|
||||
@ -150,7 +158,8 @@ interface nsIMemoryReporter : nsISupports
|
||||
*/
|
||||
const PRInt32 UNITS_BYTES = 0;
|
||||
const PRInt32 UNITS_COUNT = 1;
|
||||
const PRInt32 UNITS_PERCENTAGE = 2;
|
||||
const PRInt32 UNITS_COUNT_CUMULATIVE = 2;
|
||||
const PRInt32 UNITS_PERCENTAGE = 3;
|
||||
|
||||
/*
|
||||
* The units on the reporter's amount. See UNITS_* above.
|
||||
|
@ -208,7 +208,7 @@ NS_MEMORY_REPORTER_IMPLEMENT(Vsize,
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(PageFaultsSoft,
|
||||
"page-faults-soft",
|
||||
KIND_OTHER,
|
||||
UNITS_COUNT,
|
||||
UNITS_COUNT_CUMULATIVE,
|
||||
GetSoftPageFaults,
|
||||
"The number of soft page faults (also known as \"minor page faults\") that "
|
||||
"have occurred since the process started. A soft page fault occurs when the "
|
||||
@ -223,7 +223,7 @@ NS_MEMORY_REPORTER_IMPLEMENT(PageFaultsSoft,
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(PageFaultsHard,
|
||||
"page-faults-hard",
|
||||
KIND_OTHER,
|
||||
UNITS_COUNT,
|
||||
UNITS_COUNT_CUMULATIVE,
|
||||
GetHardPageFaults,
|
||||
"The number of hard page faults (also known as \"major page faults\") that "
|
||||
"have occurred since the process started. A hard page fault occurs when a "
|
||||
|
Loading…
Reference in New Issue
Block a user