Skip to content

Commit 358272b

Browse files
liyuying0000copybara-github
authored andcommitted
Fix result reporting and enable INFO logging in Fleetbench parallel benchmarks.
PiperOrigin-RevId: 802247987 Change-Id: I8de0e80cf541aca3b39b412a506d1760cdcb4a82
1 parent d4a4377 commit 358272b

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

fleetbench/parallel/parallel_bench.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ def main(argv: Sequence[str]) -> None:
210210
if len(argv) > 1:
211211
raise app.UsageError("Too many command-line arguments.")
212212

213+
# Sets the logging threshold to INFO.
214+
logging.set_stderrthreshold(logging.INFO)
215+
213216
shutil.rmtree(_TEMP_ROOT.value, ignore_errors=True)
214217
os.makedirs(_TEMP_ROOT.value, exist_ok=True)
215218

fleetbench/parallel/reporter.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,18 +314,25 @@ def GenerateFinalReport(
314314
# we simply copy the single run report to the final report.
315315
input_file = os.path.join(output_dir, "run_0", "results.json")
316316
if os.path.exists(input_file):
317-
with open(input_file, "r") as infile, open(output_file, "w") as outfile:
318-
outfile.write(infile.read())
317+
with open(input_file, "r") as infile:
318+
content = infile.read()
319+
with open(output_file, "w") as outfile:
320+
outfile.write(content)
321+
322+
# load the data from the content so we can print the summary.
323+
json_data = json.loads(content)
324+
data = json_data.get("benchmarks", []) # Safely get the benchmark data
325+
319326
else:
320327
logging.warning(
321328
"Warning: results.json not found in %s",
322329
os.path.join(output_dir, "run_0"),
323330
)
324-
return
325-
326-
context = AggregateFinalContext(context_list)
327-
data = AggregateFinalData(data_list)
328-
_SaveFile(output_file, data, context)
331+
return
332+
else:
333+
context = AggregateFinalContext(context_list)
334+
data = AggregateFinalData(data_list)
335+
_SaveFile(output_file, data, context)
329336

330337
df = pd.DataFrame(data)
331338
selected_columns = [

fleetbench/parallel/reporter_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,8 @@ def test_generate_final_report_single_repetition_perf_counters(self):
392392
os.makedirs(run_0_dir)
393393
input_content = (
394394
'{"context": {"key": "value"}, "benchmarks": [{"name": "benchmark_1",'
395-
' "metric_1": 10, "cycles": 100}]}'
395+
' "Count": 1, "real_time": 10, "cpu_time": 10 , "metric_1": 10,'
396+
' "cycles": 100}]}'
396397
)
397398
with open(os.path.join(run_0_dir, "results.json"), "w") as f:
398399
f.write(input_content)

0 commit comments

Comments
 (0)