diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/shared/performance/recording-common.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/shared/performance/recording-common.js')
-rw-r--r-- | devtools/shared/performance/recording-common.js | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/devtools/shared/performance/recording-common.js b/devtools/shared/performance/recording-common.js new file mode 100644 index 000000000..d0826bd18 --- /dev/null +++ b/devtools/shared/performance/recording-common.js @@ -0,0 +1,97 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +/** + * A mixin to be used for PerformanceRecordingActor, PerformanceRecordingFront, + * and LegacyPerformanceRecording for helper methods to access data. + */ + +const PerformanceRecordingCommon = exports.PerformanceRecordingCommon = { + // Private fields, only needed when a recording is started or stopped. + _console: false, + _imported: false, + _recording: false, + _completed: false, + _configuration: {}, + _startingBufferStatus: null, + _localStartTime: 0, + + // Serializable fields, necessary and sufficient for import and export. + _label: "", + _duration: 0, + _markers: null, + _frames: null, + _memory: null, + _ticks: null, + _allocations: null, + _profile: null, + _systemHost: null, + _systemClient: null, + + /** + * Helper methods for returning the status of the recording. + * These methods should be consistent on both the front and actor. + */ + isRecording: function () { return this._recording; }, + isCompleted: function () { return this._completed || this.isImported(); }, + isFinalizing: function () { return !this.isRecording() && !this.isCompleted(); }, + isConsole: function () { return this._console; }, + isImported: function () { return this._imported; }, + + /** + * Helper methods for returning configuration for the recording. + * These methods should be consistent on both the front and actor. + */ + getConfiguration: function () { return this._configuration; }, + getLabel: function () { return this._label; }, + + /** + * Gets duration of this recording, in milliseconds. + * @return number + */ + getDuration: function () { + // Compute an approximate ending time for the current recording if it is + // still in progress. This is needed to ensure that the view updates even + // when new data is not being generated. If recording is completed, use + // the duration from the profiler; if between recording and being finalized, + // use the last estimated duration. + if (this.isRecording()) { + return this._estimatedDuration = Date.now() - this._localStartTime; + } else { + return this._duration || this._estimatedDuration || 0; + } + }, + + /** + * Helper methods for returning recording data. + * These methods should be consistent on both the front and actor. + */ + getMarkers: function () { return this._markers; }, + getFrames: function () { return this._frames; }, + getMemory: function () { return this._memory; }, + getTicks: function () { return this._ticks; }, + getAllocations: function () { return this._allocations; }, + getProfile: function () { return this._profile; }, + getHostSystemInfo: function () { return this._systemHost; }, + getClientSystemInfo: function () { return this._systemClient; }, + getStartingBufferStatus: function () { return this._startingBufferStatus; }, + + getAllData: function () { + let label = this.getLabel(); + let duration = this.getDuration(); + let markers = this.getMarkers(); + let frames = this.getFrames(); + let memory = this.getMemory(); + let ticks = this.getTicks(); + let allocations = this.getAllocations(); + let profile = this.getProfile(); + let configuration = this.getConfiguration(); + let systemHost = this.getHostSystemInfo(); + let systemClient = this.getClientSystemInfo(); + + return { label, duration, markers, frames, memory, ticks, allocations, profile, configuration, systemHost, systemClient }; + }, +}; |