forked from mirrors/gecko-dev
Bug 1290142 - Lint devtools/client/performance/legacy; r=jsantell
MozReview-Commit-ID: 9zX19SxK8rw --HG-- extra : rebase_source : 54d96b55046b6447e60b2d194989dc7da3b5718d
This commit is contained in:
parent
92f73e196a
commit
72753529ec
5 changed files with 77 additions and 42 deletions
|
|
@ -84,7 +84,6 @@ devtools/client/jsonview/lib/**
|
|||
devtools/client/memory/**
|
||||
devtools/client/netmonitor/test/**
|
||||
devtools/client/netmonitor/har/test/**
|
||||
devtools/client/performance/legacy/**
|
||||
devtools/client/performance/modules/**
|
||||
devtools/client/performance/test/**
|
||||
devtools/client/projecteditor/**
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
const { Task } = require("devtools/shared/task");
|
||||
|
||||
const promise = require("promise");
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
const { Poller } = require("devtools/client/shared/poller");
|
||||
|
||||
|
|
@ -14,8 +13,8 @@ const RecordingUtils = require("devtools/shared/performance/recording-utils");
|
|||
const { TimelineFront } = require("devtools/shared/fronts/timeline");
|
||||
const { ProfilerFront } = require("devtools/shared/fronts/profiler");
|
||||
|
||||
// how often do we check the status of the profiler's circular buffer
|
||||
const PROFILER_CHECK_TIMER = 5000; // ms
|
||||
// How often do we check the status of the profiler's circular buffer in milliseconds.
|
||||
const PROFILER_CHECK_TIMER = 5000;
|
||||
|
||||
const TIMELINE_ACTOR_METHODS = [
|
||||
"start", "stop",
|
||||
|
|
@ -33,7 +32,8 @@ function LegacyProfilerFront(target) {
|
|||
this._target = target;
|
||||
this._onProfilerEvent = this._onProfilerEvent.bind(this);
|
||||
this._checkProfilerStatus = this._checkProfilerStatus.bind(this);
|
||||
this._PROFILER_CHECK_TIMER = this._target.TEST_MOCK_PROFILER_CHECK_TIMER || PROFILER_CHECK_TIMER;
|
||||
this._PROFILER_CHECK_TIMER = this._target.TEST_MOCK_PROFILER_CHECK_TIMER ||
|
||||
PROFILER_CHECK_TIMER;
|
||||
|
||||
EventEmitter.decorate(this);
|
||||
}
|
||||
|
|
@ -80,7 +80,8 @@ LegacyProfilerFront.prototype = {
|
|||
// profiler can be activated via `console.profile` or another source, like
|
||||
// the Gecko Profiler.
|
||||
if (!this._poller) {
|
||||
this._poller = new Poller(this._checkProfilerStatus, this._PROFILER_CHECK_TIMER, false);
|
||||
this._poller = new Poller(this._checkProfilerStatus, this._PROFILER_CHECK_TIMER,
|
||||
false);
|
||||
}
|
||||
if (!this._poller.isPolling()) {
|
||||
this._poller.on();
|
||||
|
|
@ -90,7 +91,13 @@ LegacyProfilerFront.prototype = {
|
|||
// nsIPerformance module will be kept recording, because it's the same instance
|
||||
// for all targets and interacts with the whole platform, so we don't want
|
||||
// to affect other clients by stopping (or restarting) it.
|
||||
let { isActive, currentTime, position, generation, totalSize } = yield this.getStatus();
|
||||
let {
|
||||
isActive,
|
||||
currentTime,
|
||||
position,
|
||||
generation,
|
||||
totalSize
|
||||
} = yield this.getStatus();
|
||||
|
||||
if (isActive) {
|
||||
return { startTime: currentTime, position, generation, totalSize };
|
||||
|
|
@ -100,7 +107,9 @@ LegacyProfilerFront.prototype = {
|
|||
// options for the nsIProfiler
|
||||
let profilerOptions = {
|
||||
entries: options.bufferSize,
|
||||
interval: options.sampleFrequency ? (1000 / (options.sampleFrequency * 1000)) : void 0
|
||||
interval: options.sampleFrequency
|
||||
? (1000 / (options.sampleFrequency * 1000))
|
||||
: void 0
|
||||
};
|
||||
|
||||
let startInfo = yield this.startProfiler(profilerOptions);
|
||||
|
|
@ -129,7 +138,7 @@ LegacyProfilerFront.prototype = {
|
|||
// If no data, the last poll for `isActive()` was wrapping up, and the target.client
|
||||
// is now null, so we no longer have data, so just abort here.
|
||||
if (!data) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// If TEST_PROFILER_FILTER_STATUS defined (via array of fields), filter
|
||||
|
|
@ -152,15 +161,16 @@ LegacyProfilerFront.prototype = {
|
|||
* Returns profile data from now since `startTime`.
|
||||
*/
|
||||
getProfile: Task.async(function* (options) {
|
||||
let profilerData = yield (CompatUtils.callFrontMethod("getProfile").call(this, options));
|
||||
let profilerData = yield (CompatUtils.callFrontMethod("getProfile")
|
||||
.call(this, options));
|
||||
// If the backend is not deduped, dedupe it ourselves, as rest of the code
|
||||
// expects a deduped profile.
|
||||
if (profilerData.profile.meta.version === 2) {
|
||||
RecordingUtils.deflateProfile(profilerData.profile);
|
||||
}
|
||||
|
||||
// If the backend does not support filtering by start and endtime on platform (< Fx40),
|
||||
// do it on the client (much slower).
|
||||
// If the backend does not support filtering by start and endtime on
|
||||
// platform (< Fx40), do it on the client (much slower).
|
||||
if (!this.traits.filterable) {
|
||||
RecordingUtils.filterSamples(profilerData.profile, options.startTime || 0);
|
||||
}
|
||||
|
|
@ -242,8 +252,12 @@ LegacyTimelineFront.prototype = {
|
|||
};
|
||||
|
||||
// Bind all the methods that directly proxy to the actor
|
||||
PROFILER_ACTOR_METHODS.forEach(m => LegacyProfilerFront.prototype[m] = CompatUtils.callFrontMethod(m));
|
||||
TIMELINE_ACTOR_METHODS.forEach(m => LegacyTimelineFront.prototype[m] = CompatUtils.callFrontMethod(m));
|
||||
PROFILER_ACTOR_METHODS.forEach(m => {
|
||||
LegacyProfilerFront.prototype[m] = CompatUtils.callFrontMethod(m);
|
||||
});
|
||||
TIMELINE_ACTOR_METHODS.forEach(m => {
|
||||
LegacyTimelineFront.prototype[m] = CompatUtils.callFrontMethod(m);
|
||||
});
|
||||
|
||||
exports.LegacyProfilerFront = LegacyProfilerFront;
|
||||
exports.LegacyTimelineFront = LegacyTimelineFront;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const promise = require("promise");
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
/**
|
||||
|
|
@ -56,7 +55,7 @@ function callFrontMethod(method) {
|
|||
// after the test ends, when tests do not wait for toolbox destruction
|
||||
// (which will destroy the actor facade, turning off the polling).
|
||||
if (!this._target || !this._target.client) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
return this._front[method].apply(this._front, arguments);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const { Cu } = require("chrome");
|
||||
const { Task } = require("devtools/shared/task");
|
||||
|
||||
const Services = require("Services");
|
||||
|
|
@ -83,6 +82,7 @@ const LegacyPerformanceFront = Class({
|
|||
yield this._registerListeners();
|
||||
|
||||
this._connecting.resolve();
|
||||
return this._connecting.promise;
|
||||
}),
|
||||
|
||||
/**
|
||||
|
|
@ -166,7 +166,8 @@ const LegacyPerformanceFront = 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: startTime }) {
|
||||
let recordings = this._recordings;
|
||||
|
||||
// Abort if a profile with this label already exists.
|
||||
|
|
@ -197,7 +198,7 @@ const LegacyPerformanceFront = 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) {
|
||||
|
|
@ -209,16 +210,16 @@ const LegacyPerformanceFront = 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) {
|
||||
console.error("console.profileEnd() called with label that does not match a recording.");
|
||||
console.error(
|
||||
"console.profileEnd() called with label that does not match a recording.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -264,12 +265,14 @@ const LegacyPerformanceFront = Class({
|
|||
*
|
||||
* @param object options
|
||||
* An options object to pass to the actors. Supported properties are
|
||||
* `withTicks`, `withMemory` and `withAllocations`, `probability`, and `maxLogLength`.
|
||||
* `withTicks`, `withMemory` and `withAllocations`, `probability`, and
|
||||
* `maxLogLength`.
|
||||
* @return object
|
||||
* A promise that is resolved once recording has started.
|
||||
*/
|
||||
startRecording: Task.async(function* (options = {}) {
|
||||
let model = new LegacyPerformanceRecording(normalizePerformanceFeatures(options, this.traits.features));
|
||||
let model = new LegacyPerformanceRecording(
|
||||
normalizePerformanceFeatures(options, this.traits.features));
|
||||
|
||||
// All actors are started asynchronously over the remote debugging protocol.
|
||||
// Get the corresponding start times from each one of them.
|
||||
|
|
@ -299,7 +302,8 @@ const LegacyPerformanceFront = Class({
|
|||
* Manually ends the recording session for the corresponding LegacyPerformanceRecording.
|
||||
*
|
||||
* @param LegacyPerformanceRecording model
|
||||
* The corresponding LegacyPerformanceRecording that belongs to the recording session wished to stop.
|
||||
* The corresponding LegacyPerformanceRecording that belongs to the recording
|
||||
* session wished to stop.
|
||||
* @return LegacyPerformanceRecording
|
||||
* Returns the same model, populated with the profiling data.
|
||||
*/
|
||||
|
|
@ -307,7 +311,7 @@ const LegacyPerformanceFront = Class({
|
|||
// If model isn't in the LegacyPerformanceFront internal store,
|
||||
// then do nothing.
|
||||
if (this._recordings.indexOf(model) === -1) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Flag the recording as no longer recording, so that `model.isRecording()`
|
||||
|
|
@ -343,7 +347,6 @@ const LegacyPerformanceFront = Class({
|
|||
timelineEndTime = yield this._timeline.stop(config);
|
||||
}
|
||||
|
||||
let systemDeferred = promise.defer();
|
||||
let form = yield this._client.listTabs();
|
||||
let systemHost = yield getDeviceFront(this._client, form).getDescription();
|
||||
let systemClient = yield getSystemInfo();
|
||||
|
|
@ -396,10 +399,18 @@ const LegacyPerformanceFront = Class({
|
|||
if (!recording.isRecording() || !this._currentBufferStatus) {
|
||||
return null;
|
||||
}
|
||||
let { position: currentPosition, totalSize, generation: currentGeneration } = this._currentBufferStatus;
|
||||
let { position: origPosition, generation: origGeneration } = recording.getStartingBufferStatus();
|
||||
let {
|
||||
position: currentPosition,
|
||||
totalSize,
|
||||
generation: currentGeneration
|
||||
} = this._currentBufferStatus;
|
||||
let {
|
||||
position: origPosition,
|
||||
generation: origGeneration
|
||||
} = recording.getStartingBufferStatus();
|
||||
|
||||
let normalizedCurrent = (totalSize * (currentGeneration - origGeneration)) + currentPosition;
|
||||
let normalizedCurrent = (totalSize * (currentGeneration - origGeneration))
|
||||
+ currentPosition;
|
||||
let percent = (normalizedCurrent - origPosition) / totalSize;
|
||||
return percent > 1 ? 1 : percent;
|
||||
},
|
||||
|
|
@ -451,16 +462,22 @@ const LegacyPerformanceFront = Class({
|
|||
});
|
||||
|
||||
/**
|
||||
* Creates an object of configurations based off of preferences for a LegacyPerformanceRecording.
|
||||
* Creates an object of configurations based off of preferences for a
|
||||
* LegacyPerformanceRecording.
|
||||
*/
|
||||
function getLegacyPerformanceRecordingPrefs() {
|
||||
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")
|
||||
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")
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const { Cc, Ci, Cu, Cr } = require("chrome");
|
||||
const { Task } = require("devtools/shared/task");
|
||||
|
||||
const PerformanceIO = require("devtools/client/performance/modules/io");
|
||||
|
|
@ -94,7 +93,8 @@ LegacyPerformanceRecording.prototype = merge({
|
|||
* Sets results available from stopping a recording from PerformanceFront.
|
||||
* Should only be called by PerformanceFront.
|
||||
*/
|
||||
_onStopRecording: Task.async(function* ({ profilerEndTime, profile, systemClient, systemHost }) {
|
||||
_onStopRecording: Task.async(function* ({ profilerEndTime, profile, systemClient,
|
||||
systemHost }) {
|
||||
// Update the duration with the accurate profilerEndTime, so we don't have
|
||||
// samples outside of the approximate duration set in `_onStoppingRecording`.
|
||||
this._duration = profilerEndTime - this._profilerStartTime;
|
||||
|
|
@ -139,7 +139,9 @@ LegacyPerformanceRecording.prototype = merge({
|
|||
// Accumulate timeline markers into an array. Furthermore, the timestamps
|
||||
// do not have a zero epoch, so offset all of them by the start time.
|
||||
case "markers": {
|
||||
if (!config.withMarkers) { break; }
|
||||
if (!config.withMarkers) {
|
||||
break;
|
||||
}
|
||||
let [markers] = data;
|
||||
RecordingUtils.offsetMarkerTimes(markers, this._timelineStartTime);
|
||||
RecordingUtils.pushAll(this._markers, markers);
|
||||
|
|
@ -147,14 +149,18 @@ LegacyPerformanceRecording.prototype = merge({
|
|||
}
|
||||
// Accumulate stack frames into an array.
|
||||
case "frames": {
|
||||
if (!config.withMarkers) { break; }
|
||||
if (!config.withMarkers) {
|
||||
break;
|
||||
}
|
||||
let [, frames] = data;
|
||||
RecordingUtils.pushAll(this._frames, frames);
|
||||
break;
|
||||
}
|
||||
// Save the accumulated refresh driver ticks.
|
||||
case "ticks": {
|
||||
if (!config.withTicks) { break; }
|
||||
if (!config.withTicks) {
|
||||
break;
|
||||
}
|
||||
let [, timestamps] = data;
|
||||
this._ticks = timestamps;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in a new issue