blob: e699f328c440a711e595226e7cfe176e21d51713 [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.
Christoffer Adamsen45f41b62024-10-09 08:09:24 +02004function getSingleResult(benchmark, commit, resultName, resultIteration = 0, warmup = false) {
Christoffer Adamsenf05505b2024-09-03 13:48:14 +02005 if (!(benchmark in commit.benchmarks)) {
6 return NaN;
7 }
Christoffer Adamsen45f41b62024-10-09 08:09:24 +02008 const benchmarkData = commit.benchmarks[benchmark];
9 const allResults = warmup ? benchmarkData.warmup : benchmarkData.results;
Christoffer Adamsenf05505b2024-09-03 13:48:14 +020010 const resultsForIteration = allResults[resultIteration];
11 // If a given iteration does not declare a result, then the result
12 // was the same as the first run.
13 if (resultIteration > 0 && !(resultName in resultsForIteration)) {
14 return allResults.first()[resultName];
15 }
16 return resultsForIteration[resultName];
17}
18
Christoffer Adamsen45f41b62024-10-09 08:09:24 +020019function getAllResults(benchmark, commit, resultName, transformation, warmup = false) {
20 if (!(benchmark in commit.benchmarks)) {
21 return NaN;
22 }
23 const benchmarkData = commit.benchmarks[benchmark];
24 if (warmup && !('warmup' in benchmarkData)) {
25 return NaN;
26 }
Christoffer Adamsenf05505b2024-09-03 13:48:14 +020027 const result = [];
Christoffer Adamsen45f41b62024-10-09 08:09:24 +020028 const allResults = warmup ? benchmarkData.warmup : benchmarkData.results;
Christoffer Adamsenf05505b2024-09-03 13:48:14 +020029 for (var iteration = 0; iteration < allResults.length; iteration++) {
Christoffer Adamsen45f41b62024-10-09 08:09:24 +020030 result.push(getSingleResult(benchmark, commit, resultName, iteration, warmup));
Christoffer Adamsenf05505b2024-09-03 13:48:14 +020031 }
Christoffer Adamsen6ede6f72024-09-16 09:20:09 +020032 if (transformation) {
33 return transformation(result);
34 }
Christoffer Adamsenf05505b2024-09-03 13:48:14 +020035 return result;
36}
Christoffer Adamsen45f41b62024-10-09 08:09:24 +020037
38function getAllWarmupResults(benchmark, commit, resultName, transformation) {
39 return getAllResults(benchmark, commit, resultName, transformation, true);
40}