diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /python/mozperftest/mozperftest/metrics/notebook/transforms/single_json.py | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'python/mozperftest/mozperftest/metrics/notebook/transforms/single_json.py')
-rw-r--r-- | python/mozperftest/mozperftest/metrics/notebook/transforms/single_json.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/python/mozperftest/mozperftest/metrics/notebook/transforms/single_json.py b/python/mozperftest/mozperftest/metrics/notebook/transforms/single_json.py new file mode 100644 index 0000000000..375615fb23 --- /dev/null +++ b/python/mozperftest/mozperftest/metrics/notebook/transforms/single_json.py @@ -0,0 +1,56 @@ +# 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/. +from mozperftest.metrics.notebook.utilities import flat + + +class SingleJsonRetriever: + """Transforms perfherder data into the standardized data format.""" + + entry_number = 0 + + def transform(self, data): + self.entry_number += 1 + + # flat(data, ()) returns a dict that have one key per dictionary path + # in the original data. + return [ + { + "data": [{"value": i, "xaxis": self.entry_number} for i in v], + "subtest": k, + } + for k, v in flat(data, ()).items() + ] + + def merge(self, sde): + grouped_data = {} + for entry in sde: + subtest = entry["subtest"] + data = grouped_data.get(subtest, []) + data.extend(entry["data"]) + grouped_data.update({subtest: data}) + + merged_data = [{"data": v, "subtest": k} for k, v in grouped_data.items()] + + self.entry_number = 0 + return merged_data + + def summary(self, suite): + """Summarize a suite of perfherder data into a single value. + + Returning None means that there's no summary. Otherwise, an integer + or float must be returned. + + Only available in the Perfherder layer. + """ + return None + + def subtest_summary(self, subtest): + """Summarize a set of replicates for a given subtest. + + By default, it returns a None so we fall back to using the + average of the replicates which is the default. + + Only available in the Perfherder layer. + """ + return None |