(results: Iterable[NormalizedResult], metric: str)
| 178 | |
| 179 | |
| 180 | def metric_value(results: Iterable[NormalizedResult], metric: str) -> float | int | None: |
| 181 | result_list = list(results) |
| 182 | if metric == "count": |
| 183 | return len(result_list) |
| 184 | if metric == "success_count": |
| 185 | return sum(1 for item in result_list if item.status == "success") |
| 186 | if metric == "failed_count": |
| 187 | return sum(1 for item in result_list if item.status == "failed") |
| 188 | if metric == "total_runtime": |
| 189 | return _total_runtime(result_list) |
| 190 | if metric == "average_runtime": |
| 191 | return _average_runtime(result_list) |
| 192 | if metric == "success_rate": |
| 193 | return _success_rate(result_list) |
| 194 | raise ValueError(f"Unsupported metric: {metric}") |
| 195 | |
| 196 | |
| 197 | def group_key(item: NormalizedResult, field: str) -> str: |
no test coverage detected