Skip to content

Commit 2b20ab6

Browse files
committed
Allow result file to be re-displayed
1 parent 53420e4 commit 2b20ab6

File tree

5 files changed

+41
-9
lines changed

5 files changed

+41
-9
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ cython_debug/
168168
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
169169
# and can be added to the global gitignore or merged into this file. For a more nuclear
170170
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
171-
#.idea/
171+
.idea/
172172

173173

174174
# MacOS files

src/guidellm/__main__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import click
88

99
from guidellm.backend import BackendType
10-
from guidellm.benchmark import ProfileType, benchmark_generative_text
10+
from guidellm.benchmark import ProfileType, benchmark_generative_text, display_benchmarks_report
1111
from guidellm.config import print_config
1212
from guidellm.preprocess.dataset import ShortPromptStrategy, process_dataset
1313
from guidellm.scheduler import StrategyType
@@ -282,6 +282,16 @@ def benchmark(
282282
)
283283

284284

285+
@cli.command(help="Redisplay a saved benchmark report.")
286+
@click.argument(
287+
"path",
288+
type=click.Path(),
289+
default=Path.cwd() / "benchmarks.json",
290+
)
291+
def display(path):
292+
asyncio.run(display_benchmarks_report(path))
293+
294+
285295
def decode_escaped_str(_ctx, _param, value):
286296
"""
287297
Click auto adds characters. For example, when using --pad-char "\n",

src/guidellm/benchmark/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
StatusBreakdown,
1313
)
1414
from .benchmarker import Benchmarker, BenchmarkerResult, GenerativeBenchmarker
15-
from .entrypoints import benchmark_generative_text
15+
from .entrypoints import benchmark_generative_text, display_benchmarks_report
1616
from .output import GenerativeBenchmarksConsole, GenerativeBenchmarksReport
1717
from .profile import (
1818
AsyncProfile,

src/guidellm/benchmark/entrypoints.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from collections.abc import Iterable
23
from pathlib import Path
34
from typing import Any, Literal, Optional, Union
@@ -121,13 +122,8 @@ async def benchmark_generative_text(
121122
)
122123

123124
if output_console:
124-
orig_enabled = console.enabled
125-
console.enabled = True
126125
console.benchmarks = report.benchmarks
127-
console.print_benchmarks_metadata()
128-
console.print_benchmarks_info()
129-
console.print_benchmarks_stats()
130-
console.enabled = orig_enabled
126+
console.print_full_report()
131127

132128
if output_path:
133129
console.print_line("\nSaving benchmarks report...")
@@ -139,3 +135,12 @@ async def benchmark_generative_text(
139135
console.print_line("\nBenchmarking complete.")
140136

141137
return report, saved_path
138+
139+
async def display_benchmarks_report(file: str):
140+
console = GenerativeBenchmarksConsole(enabled=True)
141+
if not os.path.exists(file):
142+
console.print_line(f"File {file} not found.")
143+
return
144+
report = GenerativeBenchmarksReport.load_file(file)
145+
console.benchmarks = report.benchmarks
146+
console.print_full_report()

src/guidellm/benchmark/output.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,3 +944,20 @@ def print_benchmarks_stats(self):
944944
title="Benchmarks Stats",
945945
sections=sections,
946946
)
947+
948+
def print_full_report(self):
949+
"""
950+
Print out the benchmark statistics to the console.
951+
Temporarily enables the console if it's disabled.
952+
953+
Format:
954+
- Metadata
955+
- Info
956+
- Stats
957+
"""
958+
orig_enabled = self.enabled
959+
self.enabled = True
960+
self.print_benchmarks_metadata()
961+
self.print_benchmarks_info()
962+
self.print_benchmarks_stats()
963+
self.enabled = orig_enabled

0 commit comments

Comments
 (0)