зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1325191 - Fix ESLint errors in devtools/server/performance/. r=jryans
MozReview-Commit-ID: Imv1Ntr7E1x
This commit is contained in:
Родитель
f8ea7f6a39
Коммит
2b0b85f4b0
|
@ -112,7 +112,6 @@ devtools/server/actors/*.js
|
|||
!devtools/server/actors/webbrowser.js
|
||||
!devtools/server/actors/webextension.js
|
||||
!devtools/server/actors/webextension-inspected-window.js
|
||||
devtools/server/performance/**
|
||||
devtools/server/tests/browser/**
|
||||
!devtools/server/tests/browser/browser_webextension_inspected_window.js
|
||||
devtools/server/tests/mochitest/**
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const { on, once, off, emit } = require("sdk/event/core");
|
||||
const { on, off } = require("sdk/event/core");
|
||||
const { Class } = require("sdk/core/heritage");
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@ const { Class } = require("sdk/core/heritage");
|
|||
* and monitors framerate over time. The actor wrapper around this
|
||||
* can be found at devtools/server/actors/framerate.js
|
||||
*/
|
||||
var Framerate = exports.Framerate = Class({
|
||||
exports.Framerate = Class({
|
||||
initialize: function (tabActor) {
|
||||
this.tabActor = tabActor;
|
||||
this._contentWin = tabActor.window;
|
||||
|
|
|
@ -32,7 +32,7 @@ loader.lazyRequireGetter(this, "ChildProcessActor",
|
|||
* send information over RDP, and TimelineActor for using more light-weight
|
||||
* utilities like GC events and measuring memory consumption.
|
||||
*/
|
||||
var Memory = exports.Memory = Class({
|
||||
exports.Memory = Class({
|
||||
extends: EventTarget,
|
||||
|
||||
/**
|
||||
|
@ -148,9 +148,12 @@ var Memory = exports.Memory = Class({
|
|||
// If we are observing the whole process, then scope the snapshot
|
||||
// accordingly. Otherwise, use the debugger's debuggees.
|
||||
if (!boundaries) {
|
||||
boundaries = this.parent instanceof ChromeActor || this.parent instanceof ChildProcessActor
|
||||
? { runtime: true }
|
||||
: { debugger: this.dbg };
|
||||
if (this.parent instanceof ChromeActor ||
|
||||
this.parent instanceof ChildProcessActor) {
|
||||
boundaries = { runtime: true };
|
||||
} else {
|
||||
boundaries = { debugger: this.dbg };
|
||||
}
|
||||
}
|
||||
const path = ThreadSafeChromeUtils.saveHeapSnapshot(boundaries);
|
||||
return HeapSnapshotFileUtils.getSnapshotIdFromPath(path);
|
||||
|
@ -168,40 +171,42 @@ var Memory = exports.Memory = Class({
|
|||
* Start recording allocation sites.
|
||||
*
|
||||
* @param {number} options.probability
|
||||
* The probability we sample any given allocation when recording allocations.
|
||||
* Must be between 0 and 1 -- defaults to 1.
|
||||
* The probability we sample any given allocation when recording
|
||||
* allocations. Must be between 0 and 1 -- defaults to 1.
|
||||
* @param {number} options.maxLogLength
|
||||
* The maximum number of allocation events to keep in the
|
||||
* log. If new allocs occur while at capacity, oldest
|
||||
* allocations are lost. Must fit in a 32 bit signed integer.
|
||||
* @param {number} options.drainAllocationsTimeout
|
||||
* A number in milliseconds of how often, at least, an `allocation` event
|
||||
* gets emitted (and drained), and also emits and drains on every GC event,
|
||||
* resetting the timer.
|
||||
* A number in milliseconds of how often, at least, an `allocation`
|
||||
* event gets emitted (and drained), and also emits and drains on every
|
||||
* GC event, resetting the timer.
|
||||
*/
|
||||
startRecordingAllocations: expectState("attached", function (options = {}) {
|
||||
startRecordingAllocations: expectState("attached", function ({
|
||||
probability = 1,
|
||||
drainAllocationsTimeout = null,
|
||||
maxLogLength = null
|
||||
}) {
|
||||
if (this.isRecordingAllocations()) {
|
||||
return this._getCurrentTime();
|
||||
}
|
||||
|
||||
this._frameCache.initFrames();
|
||||
|
||||
this.dbg.memory.allocationSamplingProbability = options.probability != null
|
||||
? options.probability
|
||||
: 1.0;
|
||||
|
||||
this.drainAllocationsTimeoutTimer = typeof options.drainAllocationsTimeout === "number" ? options.drainAllocationsTimeout : null;
|
||||
this.dbg.memory.allocationSamplingProbability = probability;
|
||||
this.drainAllocationsTimeoutTimer = drainAllocationsTimeout;
|
||||
|
||||
if (this.drainAllocationsTimeoutTimer != null) {
|
||||
if (this._poller) {
|
||||
this._poller.disarm();
|
||||
}
|
||||
this._poller = new DeferredTask(this._emitAllocations, this.drainAllocationsTimeoutTimer);
|
||||
this._poller = new DeferredTask(this._emitAllocations,
|
||||
this.drainAllocationsTimeoutTimer);
|
||||
this._poller.arm();
|
||||
}
|
||||
|
||||
if (options.maxLogLength != null) {
|
||||
this.dbg.memory.maxAllocationsLogLength = options.maxLogLength;
|
||||
if (maxLogLength != null) {
|
||||
this.dbg.memory.maxAllocationsLogLength = maxLogLength;
|
||||
}
|
||||
this.dbg.memory.trackingAllocationSites = true;
|
||||
|
||||
|
@ -262,7 +267,8 @@ var Memory = exports.Memory = Class({
|
|||
* line: <line number for this frame>,
|
||||
* column: <column number for this frame>,
|
||||
* source: <filename string for this frame>,
|
||||
* functionDisplayName: <this frame's inferred function name function or null>,
|
||||
* functionDisplayName:
|
||||
* <this frame's inferred function name function or null>,
|
||||
* parent: <index into "frames">
|
||||
* },
|
||||
* ...
|
||||
|
@ -369,7 +375,8 @@ var Memory = exports.Memory = Class({
|
|||
|
||||
try {
|
||||
this._mgr.sizeOfTab(this.parent.window, jsObjectsSize, jsStringsSize, jsOtherSize,
|
||||
domSize, styleSize, otherSize, totalSize, jsMilliseconds, nonJSMilliseconds);
|
||||
domSize, styleSize, otherSize, totalSize, jsMilliseconds,
|
||||
nonJSMilliseconds);
|
||||
result.total = totalSize.value;
|
||||
result.domSize = domSize.value;
|
||||
result.styleSize = styleSize.value;
|
||||
|
@ -404,10 +411,10 @@ var Memory = exports.Memory = Class({
|
|||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Called on `drainAllocationsTimeoutTimer` interval if and only if set during `startRecordingAllocations`,
|
||||
* or on a garbage collection event if drainAllocationsTimeout was set.
|
||||
* Called on `drainAllocationsTimeoutTimer` interval if and only if set
|
||||
* during `startRecordingAllocations`, or on a garbage collection event if
|
||||
* drainAllocationsTimeout was set.
|
||||
* Drains allocation log and emits as an event and restarts the timer.
|
||||
*/
|
||||
_emitAllocations: function () {
|
||||
|
@ -419,7 +426,8 @@ var Memory = exports.Memory = Class({
|
|||
* Accesses the docshell to return the current process time.
|
||||
*/
|
||||
_getCurrentTime: function () {
|
||||
return (this.parent.isRootActor ? this.parent.docShell : this.parent.originalDocShell).now();
|
||||
return (this.parent.isRootActor ? this.parent.docShell :
|
||||
this.parent.originalDocShell).now();
|
||||
},
|
||||
|
||||
});
|
||||
|
|
|
@ -19,8 +19,8 @@ const PROFILER_SYSTEM_EVENTS = [
|
|||
"profiler-stopped"
|
||||
];
|
||||
|
||||
// How often the "profiler-status" is emitted by default
|
||||
const BUFFER_STATUS_INTERVAL_DEFAULT = 5000; // ms
|
||||
// How often the "profiler-status" is emitted by default (in ms)
|
||||
const BUFFER_STATUS_INTERVAL_DEFAULT = 5000;
|
||||
|
||||
loader.lazyGetter(this, "nsIProfilerModule", () => {
|
||||
return Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
|
||||
|
@ -174,12 +174,12 @@ const ProfilerManager = (function () {
|
|||
*
|
||||
* @param number startTime
|
||||
* Since the circular buffer will only grow as long as the profiler lives,
|
||||
* the buffer can contain unwanted samples. Pass in a `startTime` to only retrieve
|
||||
* samples that took place after the `startTime`, with 0 being when the profiler
|
||||
* just started.
|
||||
* the buffer can contain unwanted samples. Pass in a `startTime` to only
|
||||
* retrieve samples that took place after the `startTime`, with 0 being
|
||||
* when the profiler just started.
|
||||
* @param boolean stringify
|
||||
* Whether or not the returned profile object should be a string or not to save
|
||||
* JSON parse/stringify cycle if emitting over RDP.
|
||||
* Whether or not the returned profile object should be a string or not to
|
||||
* save JSON parse/stringify cycle if emitting over RDP.
|
||||
*/
|
||||
getProfile: function (options) {
|
||||
let startTime = options.startTime || 0;
|
||||
|
@ -238,7 +238,13 @@ const ProfilerManager = (function () {
|
|||
let isActive = nsIProfilerModule.IsActive();
|
||||
let elapsedTime = isActive ? nsIProfilerModule.getElapsedTime() : undefined;
|
||||
let { position, totalSize, generation } = this.getBufferInfo();
|
||||
return { isActive: isActive, currentTime: elapsedTime, position, totalSize, generation };
|
||||
return {
|
||||
isActive,
|
||||
currentTime: elapsedTime,
|
||||
position,
|
||||
totalSize,
|
||||
generation
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -247,7 +253,9 @@ const ProfilerManager = (function () {
|
|||
* profiler is stopped.
|
||||
*/
|
||||
getSharedLibraryInformation: function () {
|
||||
return { sharedLibraryInformation: nsIProfilerModule.getSharedLibraryInformation() };
|
||||
return {
|
||||
sharedLibraryInformation: nsIProfilerModule.getSharedLibraryInformation()
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -276,7 +284,8 @@ const ProfilerManager = (function () {
|
|||
// If the event was generated from `console.profile` or `console.profileEnd`
|
||||
// we need to start the profiler right away and then just notify the client.
|
||||
// Otherwise, we'll lose precious samples.
|
||||
if (topic === "console-api-profiler" && (action === "profile" || action === "profileEnd")) {
|
||||
if (topic === "console-api-profiler" &&
|
||||
(action === "profile" || action === "profileEnd")) {
|
||||
let { isActive, currentTime } = this.isActive();
|
||||
|
||||
// Start the profiler only if it wasn't already active. Otherwise, any
|
||||
|
@ -284,10 +293,9 @@ const ProfilerManager = (function () {
|
|||
if (!isActive && action === "profile") {
|
||||
this.start();
|
||||
details = { profileLabel, currentTime: 0 };
|
||||
}
|
||||
// Otherwise, if inactive and a call to profile end, do nothing
|
||||
// and don't emit event.
|
||||
else if (!isActive) {
|
||||
} else if (!isActive) {
|
||||
// Otherwise, if inactive and a call to profile end, do nothing
|
||||
// and don't emit event.
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -340,7 +348,9 @@ const ProfilerManager = (function () {
|
|||
* @param {object} data
|
||||
*/
|
||||
emitEvent: function (eventName, data) {
|
||||
let subscribers = Array.from(consumers).filter(c => c.subscribedEvents.has(eventName));
|
||||
let subscribers = Array.from(consumers).filter(c => {
|
||||
return c.subscribedEvents.has(eventName);
|
||||
});
|
||||
|
||||
for (let subscriber of subscribers) {
|
||||
events.emit(subscriber, eventName, data);
|
||||
|
@ -377,12 +387,12 @@ const ProfilerManager = (function () {
|
|||
_updateProfilerStatusPolling: function () {
|
||||
if (this._profilerStatusSubscribers > 0 && nsIProfilerModule.IsActive()) {
|
||||
if (!this._poller) {
|
||||
this._poller = new DeferredTask(this._emitProfilerStatus.bind(this), this._profilerStatusInterval);
|
||||
this._poller = new DeferredTask(this._emitProfilerStatus.bind(this),
|
||||
this._profilerStatusInterval);
|
||||
}
|
||||
this._poller.arm();
|
||||
}
|
||||
// No subscribers; turn off if it exists.
|
||||
else if (this._poller) {
|
||||
} else if (this._poller) {
|
||||
// No subscribers; turn off if it exists.
|
||||
this._poller.disarm();
|
||||
}
|
||||
},
|
||||
|
@ -414,47 +424,65 @@ var Profiler = exports.Profiler = Class({
|
|||
/**
|
||||
* @see ProfilerManager.start
|
||||
*/
|
||||
start: function (options) { return ProfilerManager.start(options); },
|
||||
start: function (options) {
|
||||
return ProfilerManager.start(options);
|
||||
},
|
||||
|
||||
/**
|
||||
* @see ProfilerManager.stop
|
||||
*/
|
||||
stop: function () { return ProfilerManager.stop(); },
|
||||
stop: function () {
|
||||
return ProfilerManager.stop();
|
||||
},
|
||||
|
||||
/**
|
||||
* @see ProfilerManager.getProfile
|
||||
*/
|
||||
getProfile: function (request = {}) { return ProfilerManager.getProfile(request); },
|
||||
getProfile: function (request = {}) {
|
||||
return ProfilerManager.getProfile(request);
|
||||
},
|
||||
|
||||
/**
|
||||
* @see ProfilerManager.getFeatures
|
||||
*/
|
||||
getFeatures: function () { return ProfilerManager.getFeatures(); },
|
||||
getFeatures: function () {
|
||||
return ProfilerManager.getFeatures();
|
||||
},
|
||||
|
||||
/**
|
||||
* @see ProfilerManager.getBufferInfo
|
||||
*/
|
||||
getBufferInfo: function () { return ProfilerManager.getBufferInfo(); },
|
||||
getBufferInfo: function () {
|
||||
return ProfilerManager.getBufferInfo();
|
||||
},
|
||||
|
||||
/**
|
||||
* @see ProfilerManager.getStartOptions
|
||||
*/
|
||||
getStartOptions: function () { return ProfilerManager.getStartOptions(); },
|
||||
getStartOptions: function () {
|
||||
return ProfilerManager.getStartOptions();
|
||||
},
|
||||
|
||||
/**
|
||||
* @see ProfilerManager.isActive
|
||||
*/
|
||||
isActive: function () { return ProfilerManager.isActive(); },
|
||||
isActive: function () {
|
||||
return ProfilerManager.isActive();
|
||||
},
|
||||
|
||||
/**
|
||||
* @see ProfilerManager.isActive
|
||||
*/
|
||||
getSharedLibraryInformation: function () { return ProfilerManager.getSharedLibraryInformation(); },
|
||||
getSharedLibraryInformation: function () {
|
||||
return ProfilerManager.getSharedLibraryInformation();
|
||||
},
|
||||
|
||||
/**
|
||||
* @see ProfilerManager.setProfilerStatusInterval
|
||||
*/
|
||||
setProfilerStatusInterval: function (interval) { return ProfilerManager.setProfilerStatusInterval(interval); },
|
||||
setProfilerStatusInterval: function (interval) {
|
||||
return ProfilerManager.setProfilerStatusInterval(interval);
|
||||
},
|
||||
|
||||
/**
|
||||
* Subscribes this instance to one of several events defined in
|
||||
|
@ -535,7 +563,8 @@ function cycleBreaker(key, value) {
|
|||
*/
|
||||
function sanitizeHandler(handler, identifier) {
|
||||
return DevToolsUtils.makeInfallible(function (subject, topic, data) {
|
||||
subject = (subject && !Cu.isXrayWrapper(subject) && subject.wrappedJSObject) || subject;
|
||||
subject = (subject && !Cu.isXrayWrapper(subject) && subject.wrappedJSObject)
|
||||
|| subject;
|
||||
subject = JSON.parse(JSON.stringify(subject, cycleBreaker));
|
||||
data = (data && !Cu.isXrayWrapper(data) && data.wrappedJSObject) || data;
|
||||
data = JSON.parse(JSON.stringify(data, cycleBreaker));
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const { Cc, Ci, Cu, Cr } = require("chrome");
|
||||
const { Cu } = require("chrome");
|
||||
const { Task } = require("devtools/shared/task");
|
||||
|
||||
loader.lazyRequireGetter(this, "Services");
|
||||
|
@ -52,7 +52,7 @@ const DRAIN_ALLOCATIONS_TIMEOUT = 2000;
|
|||
* @param Target target
|
||||
* The target owning this connection.
|
||||
*/
|
||||
const PerformanceRecorder = exports.PerformanceRecorder = Class({
|
||||
exports.PerformanceRecorder = Class({
|
||||
extends: EventTarget,
|
||||
|
||||
initialize: function (conn, tabActor) {
|
||||
|
@ -171,7 +171,7 @@ const PerformanceRecorder = exports.PerformanceRecorder = Class({
|
|||
* The time (in milliseconds) when the call was made, relative to when
|
||||
* the nsIProfiler module was started.
|
||||
*/
|
||||
_onConsoleProfileStart: Task.async(function* ({ profileLabel, currentTime: startTime }) {
|
||||
_onConsoleProfileStart: Task.async(function* ({ profileLabel, currentTime }) {
|
||||
let recordings = this._recordings;
|
||||
|
||||
// Abort if a profile with this label already exists.
|
||||
|
@ -183,7 +183,7 @@ const PerformanceRecorder = exports.PerformanceRecorder = Class({
|
|||
// expecting a recording very soon.
|
||||
events.emit(this, "console-profile-start");
|
||||
|
||||
let model = yield this.startRecording(extend({}, getPerformanceRecordingPrefs(), {
|
||||
yield this.startRecording(extend({}, getPerformanceRecordingPrefs(), {
|
||||
console: true,
|
||||
label: profileLabel
|
||||
}));
|
||||
|
@ -204,7 +204,7 @@ const PerformanceRecorder = exports.PerformanceRecorder = Class({
|
|||
if (!data) {
|
||||
return;
|
||||
}
|
||||
let { profileLabel, currentTime: endTime } = data;
|
||||
let { profileLabel } = data;
|
||||
|
||||
let pending = this._recordings.filter(r => r.isConsole() && r.isRecording());
|
||||
if (pending.length === 0) {
|
||||
|
@ -216,16 +216,16 @@ const PerformanceRecorder = exports.PerformanceRecorder = Class({
|
|||
// a label was used in profileEnd(). If no matches, abort.
|
||||
if (profileLabel) {
|
||||
model = pending.find(e => e.getLabel() === profileLabel);
|
||||
}
|
||||
// If no label supplied, pop off the most recent pending console recording
|
||||
else {
|
||||
} else {
|
||||
// If no label supplied, pop off the most recent pending console recording
|
||||
model = pending[pending.length - 1];
|
||||
}
|
||||
|
||||
// If `profileEnd()` was called with a label, and there are no matching
|
||||
// sessions, abort.
|
||||
if (!model) {
|
||||
Cu.reportError("console.profileEnd() called with label that does not match a recording.");
|
||||
Cu.reportError(
|
||||
"console.profileEnd() called with label that does not match a recording.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ const PerformanceRecorder = exports.PerformanceRecorder = Class({
|
|||
let reasons = [];
|
||||
|
||||
if (!Profiler.canProfile()) {
|
||||
success = false,
|
||||
success = false;
|
||||
reasons.push("profiler-unavailable");
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,9 @@ const PerformanceRecorder = exports.PerformanceRecorder = Class({
|
|||
if (data.isActive) {
|
||||
return data;
|
||||
}
|
||||
let startData = yield this._profiler.start(mapRecordingOptions("profiler", options));
|
||||
let startData = yield this._profiler.start(
|
||||
mapRecordingOptions("profiler", options)
|
||||
);
|
||||
|
||||
// If no current time is exposed from starting, set it to 0 -- this is an
|
||||
// older Gecko that does not return its starting time, and uses an epoch based
|
||||
|
@ -347,9 +349,10 @@ const PerformanceRecorder = exports.PerformanceRecorder = Class({
|
|||
if (this._memory.getState() === "detached") {
|
||||
this._memory.attach();
|
||||
}
|
||||
memoryStart = this._memory.startRecordingAllocations(extend(mapRecordingOptions("memory", options), {
|
||||
let recordingOptions = extend(mapRecordingOptions("memory", options), {
|
||||
drainAllocationsTimeout: DRAIN_ALLOCATIONS_TIMEOUT
|
||||
}));
|
||||
});
|
||||
memoryStart = this._memory.startRecordingAllocations(recordingOptions);
|
||||
}
|
||||
|
||||
let [profilerStartData, timelineStartData, memoryStartData] = yield promise.all([
|
||||
|
@ -359,7 +362,11 @@ const PerformanceRecorder = exports.PerformanceRecorder = Class({
|
|||
let data = Object.create(null);
|
||||
// Filter out start times that are not actually used (0 or undefined), and
|
||||
// find the earliest time since all sources use same epoch.
|
||||
let startTimes = [profilerStartData.currentTime, memoryStartData, timelineStartData].filter(Boolean);
|
||||
let startTimes = [
|
||||
profilerStartData.currentTime,
|
||||
memoryStartData,
|
||||
timelineStartData
|
||||
].filter(Boolean);
|
||||
data.startTime = Math.min(...startTimes);
|
||||
data.position = profilerStartData.position;
|
||||
data.generation = profilerStartData.generation;
|
||||
|
@ -379,7 +386,8 @@ const PerformanceRecorder = exports.PerformanceRecorder = Class({
|
|||
* Manually ends the recording session for the corresponding PerformanceRecording.
|
||||
*
|
||||
* @param PerformanceRecording model
|
||||
* The corresponding PerformanceRecording that belongs to the recording session wished to stop.
|
||||
* The corresponding PerformanceRecording that belongs to the recording
|
||||
* session wished to stop.
|
||||
* @return PerformanceRecording
|
||||
* Returns the same model, populated with the profiling data.
|
||||
*/
|
||||
|
@ -394,7 +402,6 @@ const PerformanceRecorder = exports.PerformanceRecorder = Class({
|
|||
// Flag the recording as no longer recording, so that `model.isRecording()`
|
||||
// is false. Do this before we fetch all the data, and then subsequently
|
||||
// the recording can be considered "completed".
|
||||
let endTime = Date.now();
|
||||
events.emit(this, "recording-stopping", model);
|
||||
|
||||
// Currently there are two ways profiles stop recording. Either manually in the
|
||||
|
@ -480,15 +487,19 @@ const PerformanceRecorder = exports.PerformanceRecorder = Class({
|
|||
});
|
||||
|
||||
/**
|
||||
* Creates an object of configurations based off of preferences for a PerformanceRecording.
|
||||
* Creates an object of configurations based off of
|
||||
* preferences for a PerformanceRecording.
|
||||
*/
|
||||
function getPerformanceRecordingPrefs() {
|
||||
return {
|
||||
withMarkers: true,
|
||||
withMemory: Services.prefs.getBoolPref("devtools.performance.ui.enable-memory"),
|
||||
withTicks: Services.prefs.getBoolPref("devtools.performance.ui.enable-framerate"),
|
||||
withAllocations: Services.prefs.getBoolPref("devtools.performance.ui.enable-allocations"),
|
||||
allocationsSampleProbability: +Services.prefs.getCharPref("devtools.performance.memory.sample-probability"),
|
||||
allocationsMaxLogLength: Services.prefs.getIntPref("devtools.performance.memory.max-log-length")
|
||||
withAllocations:
|
||||
Services.prefs.getBoolPref("devtools.performance.ui.enable-allocations"),
|
||||
allocationsSampleProbability:
|
||||
+Services.prefs.getCharPref("devtools.performance.memory.sample-probability"),
|
||||
allocationsMaxLogLength:
|
||||
Services.prefs.getIntPref("devtools.performance.memory.max-log-length")
|
||||
};
|
||||
}
|
||||
|
|
|
@ -33,13 +33,13 @@ loader.lazyRequireGetter(this, "EventTarget", "sdk/event/target", true);
|
|||
|
||||
// How often do we pull markers from the docShells, and therefore, how often do
|
||||
// we send events to the front (knowing that when there are no markers in the
|
||||
// docShell, no event is sent).
|
||||
const DEFAULT_TIMELINE_DATA_PULL_TIMEOUT = 200; // ms
|
||||
// docShell, no event is sent). In milliseconds.
|
||||
const DEFAULT_TIMELINE_DATA_PULL_TIMEOUT = 200;
|
||||
|
||||
/**
|
||||
* The timeline actor pops and forwards timeline markers registered in docshells.
|
||||
*/
|
||||
var Timeline = exports.Timeline = Class({
|
||||
exports.Timeline = Class({
|
||||
extends: EventTarget,
|
||||
|
||||
/**
|
||||
|
@ -135,7 +135,9 @@ var Timeline = exports.Timeline = Class({
|
|||
marker.stack = this._stackFrames.addFrame(Cu.waiveXrays(marker.stack));
|
||||
}
|
||||
if (marker.endStack) {
|
||||
marker.endStack = this._stackFrames.addFrame(Cu.waiveXrays(marker.endStack));
|
||||
marker.endStack = this._stackFrames.addFrame(
|
||||
Cu.waiveXrays(marker.endStack)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,11 +332,13 @@ var Timeline = exports.Timeline = Class({
|
|||
* take the data and make it look like the rest of our markers.
|
||||
*
|
||||
* A GC "marker" here represents a full GC cycle, which may contain several incremental
|
||||
* events within its `collection` array. The marker contains a `reason` field, indicating
|
||||
* why there was a GC, and may contain a `nonincrementalReason` when SpiderMonkey could
|
||||
* not incrementally collect garbage.
|
||||
* events within its `collection` array. The marker contains a `reason` field,
|
||||
* indicating why there was a GC, and may contain a `nonincrementalReason` when
|
||||
* SpiderMonkey could not incrementally collect garbage.
|
||||
*/
|
||||
_onGarbageCollection: function ({ collections, gcCycleNumber, reason, nonincrementalReason }) {
|
||||
_onGarbageCollection: function ({
|
||||
collections, gcCycleNumber, reason, nonincrementalReason
|
||||
}) {
|
||||
let docShells = this.docShells;
|
||||
if (!this._isRecording || !docShells.length) {
|
||||
return;
|
||||
|
@ -342,7 +346,9 @@ var Timeline = exports.Timeline = Class({
|
|||
|
||||
let endTime = docShells[0].now();
|
||||
|
||||
events.emit(this, "markers", collections.map(({ startTimestamp: start, endTimestamp: end }) => {
|
||||
events.emit(this, "markers", collections.map(({
|
||||
startTimestamp: start, endTimestamp: end
|
||||
}) => {
|
||||
return {
|
||||
name: "GarbageCollection",
|
||||
causeName: reason,
|
||||
|
|
Загрузка…
Ссылка в новой задаче