зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1078870 - Make the Developer HUD log memory changes in ADB. r=ochameau
This commit is contained in:
Родитель
ee04d4c6ee
Коммит
284d411840
|
@ -56,8 +56,9 @@ let developerHUD = {
|
|||
},
|
||||
|
||||
init: function dwp_init() {
|
||||
if (this._client)
|
||||
if (this._client) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DebuggerServer.initialized) {
|
||||
RemoteDebugger.initServer();
|
||||
|
@ -91,8 +92,9 @@ let developerHUD = {
|
|||
},
|
||||
|
||||
uninit: function dwp_uninit() {
|
||||
if (!this._client)
|
||||
if (!this._client) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let frame of this._targets.keys()) {
|
||||
this.untrackFrame(frame);
|
||||
|
@ -109,8 +111,9 @@ let developerHUD = {
|
|||
* on an app frame.
|
||||
*/
|
||||
trackFrame: function dwp_trackFrame(frame) {
|
||||
if (this._targets.has(frame))
|
||||
if (this._targets.has(frame)) {
|
||||
return;
|
||||
}
|
||||
|
||||
DebuggerServer.connectToChild(this._conn, frame).then(actor => {
|
||||
let target = new Target(frame, actor);
|
||||
|
@ -339,10 +342,10 @@ let consoleWatcher = {
|
|||
|
||||
if (pageError.warning || pageError.strict) {
|
||||
metric.name = 'warnings';
|
||||
output += 'warning (';
|
||||
output += 'Warning (';
|
||||
} else {
|
||||
metric.name = 'errors';
|
||||
output += 'error (';
|
||||
output += 'Error (';
|
||||
}
|
||||
|
||||
if (this._security.indexOf(pageError.category) > -1) {
|
||||
|
@ -359,12 +362,12 @@ let consoleWatcher = {
|
|||
|
||||
case 'error':
|
||||
metric.name = 'errors';
|
||||
output += 'error (console)';
|
||||
output += 'Error (console)';
|
||||
break;
|
||||
|
||||
case 'warn':
|
||||
metric.name = 'warnings';
|
||||
output += 'warning (console)';
|
||||
output += 'Warning (console)';
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -378,7 +381,7 @@ let consoleWatcher = {
|
|||
let {start, end, sourceURL, interruptible} = packet;
|
||||
metric.interruptible = interruptible;
|
||||
let duration = Math.round((end - start) * 100) / 100;
|
||||
output += 'reflow: ' + duration + 'ms';
|
||||
output += 'Reflow: ' + duration + 'ms';
|
||||
if (sourceURL) {
|
||||
output += ' ' + this.formatSourceURL(packet);
|
||||
}
|
||||
|
@ -425,6 +428,7 @@ let eventLoopLagWatcher = {
|
|||
if (this._active == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._active = value;
|
||||
|
||||
// Toggle the state of existing fronts.
|
||||
|
@ -446,7 +450,7 @@ let eventLoopLagWatcher = {
|
|||
this._fronts.set(target, front);
|
||||
|
||||
front.on('event-loop-lag', time => {
|
||||
target.update({name: 'jank', value: time}, 'jank: ' + time + 'ms');
|
||||
target.update({name: 'jank', value: time}, 'Jank: ' + time + 'ms');
|
||||
});
|
||||
|
||||
if (this._active) {
|
||||
|
@ -500,7 +504,7 @@ let memoryWatcher = {
|
|||
|
||||
update: function mw_update() {
|
||||
let watching = this._watching;
|
||||
let active = watching.memory || watching.uss;
|
||||
let active = watching.appmemory || watching.uss;
|
||||
|
||||
if (this._active) {
|
||||
for (let target of this._fronts.keys()) {
|
||||
|
@ -519,10 +523,11 @@ let memoryWatcher = {
|
|||
measure: function mw_measure(target) {
|
||||
let watch = this._watching;
|
||||
let front = this._fronts.get(target);
|
||||
let format = this.formatMemory;
|
||||
|
||||
if (watch.uss) {
|
||||
front.residentUnique().then(value => {
|
||||
target.update({name: 'uss', value: value});
|
||||
target.update({name: 'uss', value: value}, 'USS: ' + format(value));
|
||||
}, err => {
|
||||
console.error(err);
|
||||
});
|
||||
|
@ -531,36 +536,46 @@ let memoryWatcher = {
|
|||
if (watch.appmemory) {
|
||||
front.measure().then(data => {
|
||||
let total = 0;
|
||||
if (watch.jsobjects) {
|
||||
total += parseInt(data.jsObjectsSize);
|
||||
}
|
||||
if (watch.jsstrings) {
|
||||
total += parseInt(data.jsStringsSize);
|
||||
}
|
||||
if (watch.jsother) {
|
||||
total += parseInt(data.jsOtherSize);
|
||||
}
|
||||
if (watch.dom) {
|
||||
total += parseInt(data.domSize);
|
||||
}
|
||||
if (watch.style) {
|
||||
total += parseInt(data.styleSize);
|
||||
}
|
||||
if (watch.other) {
|
||||
total += parseInt(data.otherSize);
|
||||
let details = [];
|
||||
|
||||
function item(name, condition, value) {
|
||||
if (!condition) {
|
||||
return;
|
||||
}
|
||||
|
||||
let v = parseInt(value);
|
||||
total += v;
|
||||
details.push(name + ': ' + format(v));
|
||||
}
|
||||
|
||||
item('JS objects', watch.jsobjects, data.jsObjectsSize);
|
||||
item('JS strings', watch.jsstrings, data.jsStringsSize);
|
||||
item('JS other', watch.jsother, data.jsOtherSize);
|
||||
item('DOM', watch.dom, data.domSize);
|
||||
item('Style', watch.style, data.styleSize);
|
||||
item('Other', watch.other, data.otherSize);
|
||||
// TODO Also count images size (bug #976007).
|
||||
|
||||
target.update({name: 'memory', value: total});
|
||||
target.update({name: 'memory', value: total},
|
||||
'App Memory: ' + format(total) + ' (' + details.join(', ') + ')');
|
||||
}, err => {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
let timer = setTimeout(() => this.measure(target), 500);
|
||||
let timer = setTimeout(() => this.measure(target), 800);
|
||||
this._timers.set(target, timer);
|
||||
},
|
||||
|
||||
formatMemory: function mw_formatMemory(bytes) {
|
||||
var prefix = ['','K','M','G','T','P','E','Z','Y'];
|
||||
var i = 0;
|
||||
for (; bytes > 1024 && i < prefix.length; ++i) {
|
||||
bytes /= 1024;
|
||||
}
|
||||
return (Math.round(bytes * 100) / 100) + ' ' + prefix[i] + 'B';
|
||||
},
|
||||
|
||||
trackTarget: function mw_trackTarget(target) {
|
||||
target.register('uss');
|
||||
target.register('memory');
|
||||
|
|
Загрузка…
Ссылка в новой задаче