Christoffer Adamsen | f05505b | 2024-09-03 13:48:14 +0200 | [diff] [blame] | 1 | // 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 Adamsen | 45f41b6 | 2024-10-09 08:09:24 +0200 | [diff] [blame] | 4 | function getSingleResult(benchmark, commit, resultName, resultIteration = 0, warmup = false) { |
Christoffer Adamsen | f05505b | 2024-09-03 13:48:14 +0200 | [diff] [blame] | 5 | if (!(benchmark in commit.benchmarks)) { |
| 6 | return NaN; |
| 7 | } |
Christoffer Adamsen | 45f41b6 | 2024-10-09 08:09:24 +0200 | [diff] [blame] | 8 | const benchmarkData = commit.benchmarks[benchmark]; |
| 9 | const allResults = warmup ? benchmarkData.warmup : benchmarkData.results; |
Christoffer Adamsen | f05505b | 2024-09-03 13:48:14 +0200 | [diff] [blame] | 10 | 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 Adamsen | 45f41b6 | 2024-10-09 08:09:24 +0200 | [diff] [blame] | 19 | function 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 Adamsen | f05505b | 2024-09-03 13:48:14 +0200 | [diff] [blame] | 27 | const result = []; |
Christoffer Adamsen | 45f41b6 | 2024-10-09 08:09:24 +0200 | [diff] [blame] | 28 | const allResults = warmup ? benchmarkData.warmup : benchmarkData.results; |
Christoffer Adamsen | f05505b | 2024-09-03 13:48:14 +0200 | [diff] [blame] | 29 | for (var iteration = 0; iteration < allResults.length; iteration++) { |
Christoffer Adamsen | 45f41b6 | 2024-10-09 08:09:24 +0200 | [diff] [blame] | 30 | result.push(getSingleResult(benchmark, commit, resultName, iteration, warmup)); |
Christoffer Adamsen | f05505b | 2024-09-03 13:48:14 +0200 | [diff] [blame] | 31 | } |
Christoffer Adamsen | 6ede6f7 | 2024-09-16 09:20:09 +0200 | [diff] [blame] | 32 | if (transformation) { |
| 33 | return transformation(result); |
| 34 | } |
Christoffer Adamsen | f05505b | 2024-09-03 13:48:14 +0200 | [diff] [blame] | 35 | return result; |
| 36 | } |
Christoffer Adamsen | 45f41b6 | 2024-10-09 08:09:24 +0200 | [diff] [blame] | 37 | |
| 38 | function getAllWarmupResults(benchmark, commit, resultName, transformation) { |
| 39 | return getAllResults(benchmark, commit, resultName, transformation, true); |
| 40 | } |