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/xpcshell | |
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 '')
4 files changed, 122 insertions, 0 deletions
diff --git a/devtools/shared/performance/xpcshell/.eslintrc.js b/devtools/shared/performance/xpcshell/.eslintrc.js new file mode 100644 index 0000000000..6cb13c0af4 --- /dev/null +++ b/devtools/shared/performance/xpcshell/.eslintrc.js @@ -0,0 +1,10 @@ +/* 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"; + +module.exports = { + // Extend from the shared list of defined globals for mochitests. + extends: "../../../.eslintrc.xpcshell.js", +}; diff --git a/devtools/shared/performance/xpcshell/head.js b/devtools/shared/performance/xpcshell/head.js new file mode 100644 index 0000000000..a9ca67f7dd --- /dev/null +++ b/devtools/shared/performance/xpcshell/head.js @@ -0,0 +1,8 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/* exported require */ + +"use strict"; + +var { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm"); diff --git a/devtools/shared/performance/xpcshell/test_perf-utils-allocations-to-samples.js b/devtools/shared/performance/xpcshell/test_perf-utils-allocations-to-samples.js new file mode 100644 index 0000000000..e4f545300b --- /dev/null +++ b/devtools/shared/performance/xpcshell/test_perf-utils-allocations-to-samples.js @@ -0,0 +1,97 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Tests if allocations data received from the performance actor is properly + * converted to something that follows the same structure as the samples data + * received from the profiler. + */ + +add_task(function() { + const { + getProfileThreadFromAllocations, + } = require("devtools/shared/performance/recording-utils"); + const output = getProfileThreadFromAllocations(TEST_DATA); + equal( + JSON.stringify(output), + JSON.stringify(EXPECTED_OUTPUT), + "The output is correct." + ); +}); + +var TEST_DATA = { + sites: [0, 0, 1, 2, 3], + timestamps: [50, 100, 150, 200, 250], + sizes: [0, 0, 100, 200, 300], + frames: [ + null, + { + source: "A", + line: 1, + column: 2, + functionDisplayName: "x", + parent: 0, + }, + { + source: "B", + line: 3, + column: 4, + functionDisplayName: "y", + parent: 1, + }, + { + source: "C", + line: 5, + column: 6, + functionDisplayName: null, + parent: 2, + }, + ], +}; + +var EXPECTED_OUTPUT = { + name: "allocations", + samples: { + schema: { + stack: 0, + time: 1, + size: 2, + }, + data: [ + [1, 150, 100], + [2, 200, 200], + [3, 250, 300], + ], + }, + stackTable: { + schema: { + prefix: 0, + frame: 1, + }, + data: [ + null, + + // x (A:1:2) + [null, 1], + + // x (A:1:2) > y (B:3:4) + [1, 2], + + // x (A:1:2) > y (B:3:4) > C:5:6 + [2, 3], + ], + }, + frameTable: { + schema: { + location: 0, + implementation: 1, + optimizations: 2, + line: 3, + category: 4, + }, + data: [null, [0], [1], [2]], + }, + stringTable: ["x (A:1:2)", "y (B:3:4)", "C:5:6"], +}; diff --git a/devtools/shared/performance/xpcshell/xpcshell.ini b/devtools/shared/performance/xpcshell/xpcshell.ini new file mode 100644 index 0000000000..87760a972e --- /dev/null +++ b/devtools/shared/performance/xpcshell/xpcshell.ini @@ -0,0 +1,7 @@ +[DEFAULT] +tags = devtools +head = head.js +firefox-appdir = browser +skip-if = toolkit == 'android' + +[test_perf-utils-allocations-to-samples.js] |