blob: 46890d0101c01476e993ad3296e9bbb9cfe27c02 [file] [log] [blame]
Christoffer Adamsenf05505b2024-09-03 13:48:14 +02001// Copyright (c) 2024, the R8 project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4function getSingleResult(benchmark, commit, resultName, resultIteration = 0) {
5 if (!(benchmark in commit.benchmarks)) {
6 return NaN;
7 }
8 const allResults = commit.benchmarks[benchmark].results;
9 const resultsForIteration = allResults[resultIteration];
10 // If a given iteration does not declare a result, then the result
11 // was the same as the first run.
12 if (resultIteration > 0 && !(resultName in resultsForIteration)) {
13 return allResults.first()[resultName];
14 }
15 return resultsForIteration[resultName];
16}
17
18function getAllResults(benchmark, commit, resultName) {
19 const result = [];
20 const allResults = commit.benchmarks[benchmark].results;
21 for (var iteration = 0; iteration < allResults.length; iteration++) {
22 result.push(getSingleResult(benchmark, commit, resultName, iteration));
23 }
24 return result;
25}