|
4 | 4 | import json |
5 | 5 | import math |
6 | 6 | from abc import ABC, abstractmethod |
7 | | -from collections import OrderedDict |
| 7 | +from collections import OrderedDict, defaultdict |
8 | 8 | from copy import deepcopy |
9 | 9 | from datetime import datetime |
10 | 10 | from pathlib import Path |
11 | 11 | from typing import Any, ClassVar |
12 | 12 |
|
13 | 13 | from pydantic import BaseModel, ConfigDict, Field |
14 | | -from rich.console import Console |
15 | 14 | from rich.padding import Padding |
16 | 15 | from rich.text import Text |
| 16 | +from tabulate import tabulate |
17 | 17 |
|
18 | 18 | from guidellm.benchmark.profile import ( |
19 | 19 | AsyncProfile, |
|
31 | 31 | from guidellm.settings import settings |
32 | 32 | from guidellm.utils import ( |
33 | 33 | Colors, |
| 34 | + Console, |
34 | 35 | DistributionSummary, |
35 | 36 | RegistryMixin, |
36 | 37 | StatusDistributionSummary, |
37 | 38 | camelize_str, |
38 | 39 | recursive_key_update, |
| 40 | + safe_format_number, |
39 | 41 | safe_format_timestamp, |
40 | 42 | split_text_list_by_length, |
41 | 43 | ) |
@@ -175,12 +177,62 @@ async def finalize(self, report: GenerativeBenchmarksReport) -> str: |
175 | 177 | :param report: The completed benchmark report. |
176 | 178 | :return: |
177 | 179 | """ |
178 | | - self._print_benchmarks_metadata(report.benchmarks) |
179 | | - self._print_benchmarks_info(report.benchmarks) |
180 | | - self._print_benchmarks_stats(report.benchmarks) |
| 180 | + self.console.print("\n\n") |
| 181 | + self._print_report_benchmarks_info(report) |
181 | 182 |
|
182 | 183 | return "printed to console" |
183 | 184 |
|
| 185 | + def _print_report_benchmarks_info(self, report: GenerativeBenchmarksReport): |
| 186 | + benchmark_key = "\nBenchmark" |
| 187 | + start_key = "\nStart" |
| 188 | + end_key = "\nEnd" |
| 189 | + timings_key = "Duration, Warmup, Cooldown\nsec, sec, sec" |
| 190 | + requests_key = "Requests\nCompl, Incomp, Err" |
| 191 | + input_tokens_key = "Input Tokens\nCompl, Incomp, Err" |
| 192 | + output_tokens_key = "Output Tokens\nCompl, Incomp, Err" |
| 193 | + |
| 194 | + columns = defaultdict(list) |
| 195 | + |
| 196 | + for benchmark in report.benchmarks: |
| 197 | + columns[benchmark_key].append(str(benchmark.scheduler.strategy)) |
| 198 | + columns[start_key].append(safe_format_timestamp(benchmark.start_time)) |
| 199 | + columns[end_key].append(safe_format_timestamp(benchmark.end_time)) |
| 200 | + columns[timings_key].append( |
| 201 | + f"{safe_format_number(benchmark.duration)}, " |
| 202 | + f"{safe_format_number(report.args.warmup)}, " |
| 203 | + f"{safe_format_number(report.args.cooldown)}" |
| 204 | + ) |
| 205 | + columns[requests_key].append( |
| 206 | + f"{safe_format_number(benchmark.request_totals.successful)}, " |
| 207 | + f"{safe_format_number(benchmark.request_totals.incomplete)}, " |
| 208 | + f"{safe_format_number(benchmark.request_totals.errored)}" |
| 209 | + ) |
| 210 | + columns[input_tokens_key].append( |
| 211 | + f"{safe_format_number(benchmark.metrics.prompt_token_count.successful.total_sum)}, " |
| 212 | + f"{safe_format_number(benchmark.metrics.prompt_token_count.incomplete.total_sum)}, " |
| 213 | + f"{safe_format_number(benchmark.metrics.prompt_token_count.errored.total_sum)}" |
| 214 | + ) |
| 215 | + columns[output_tokens_key].append( |
| 216 | + f"{safe_format_number(benchmark.metrics.output_token_count.successful.total_sum)}, " |
| 217 | + f"{safe_format_number(benchmark.metrics.output_token_count.incomplete.total_sum)}, " |
| 218 | + f"{safe_format_number(benchmark.metrics.output_token_count.errored.total_sum)}" |
| 219 | + ) |
| 220 | + |
| 221 | + self.console.print_update("Benchmarks Info", None, "info") |
| 222 | + self.console.print( |
| 223 | + Padding( |
| 224 | + tabulate( |
| 225 | + columns, |
| 226 | + headers="keys", |
| 227 | + tablefmt="pipe", |
| 228 | + numalign="center", |
| 229 | + stralign="center", |
| 230 | + rowalign="center", |
| 231 | + ), |
| 232 | + (0, 0, 0, 2), |
| 233 | + ) |
| 234 | + ) |
| 235 | + |
184 | 236 | def _print_benchmarks_metadata(self, benchmarks: list[GenerativeBenchmark]): |
185 | 237 | start_time = benchmarks[0].run_stats.start_time |
186 | 238 | end_time = benchmarks[-1].run_stats.end_time |
|
0 commit comments