diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/shared/performance/recording-common.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/shared/performance/recording-common.js')
-rw-r--r-- | devtools/shared/performance/recording-common.js | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/devtools/shared/performance/recording-common.js b/devtools/shared/performance/recording-common.js new file mode 100644 index 0000000000..d0f1ae0c0d --- /dev/null +++ b/devtools/shared/performance/recording-common.js @@ -0,0 +1,141 @@ +/* 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. + */ + +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()) { + this._estimatedDuration = Date.now() - this._localStartTime; + return this._estimatedDuration; + } + 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() { + const label = this.getLabel(); + const duration = this.getDuration(); + const markers = this.getMarkers(); + const frames = this.getFrames(); + const memory = this.getMemory(); + const ticks = this.getTicks(); + const allocations = this.getAllocations(); + const profile = this.getProfile(); + const configuration = this.getConfiguration(); + const systemHost = this.getHostSystemInfo(); + const systemClient = this.getClientSystemInfo(); + + return { + label, + duration, + markers, + frames, + memory, + ticks, + allocations, + profile, + configuration, + systemHost, + systemClient, + }; + }, +}; |