From 2cc48b4b8726891f4f53fb8ec22342adb054051e Mon Sep 17 00:00:00 2001 From: Desiki-high Date: Wed, 26 Apr 2023 09:59:31 +0800 Subject: [PATCH] misc: make benchmark summary more clear Signed-off-by: Desiki-high --- misc/benchmark/benchmark_summary.py | 30 +++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/misc/benchmark/benchmark_summary.py b/misc/benchmark/benchmark_summary.py index e2615250623..afd7f0c908b 100644 --- a/misc/benchmark/benchmark_summary.py +++ b/misc/benchmark/benchmark_summary.py @@ -39,6 +39,7 @@ ("nydus-filelist-prefetch-master.csv", "nydus-filelist-prefetch.csv") ] +DELTA = 1.0 class BenchmarkSummary: def __init__(self, mode): @@ -92,12 +93,29 @@ def print_compare(file_master: str, file: str): rows = csv.reader(f) for row in rows: pull_elapsed, create_elapsed, run_elapsed, total_elapsed, image_size, read_amount, read_count = row - with open(file_master, 'r', newline='') as f: - rows = csv.reader(f) - for row in rows: - pull_elapsed_master, create_elapsed_master, run_elapsed_master, total_elapsed_master, image_size_master, read_amount_master, read_count_master = row - print(f"|{filename}|{pull_elapsed} /{pull_elapsed_master}|{create_elapsed} /{create_elapsed_master}|{run_elapsed} /{run_elapsed_master}|{total_elapsed} /{total_elapsed_master}|{image_size} / {image_size_master}|{read_amount} / {read_amount_master}|{read_count} / {read_count_master}|") - + with open(file_master, 'r', newline='') as f: + rows = csv.reader(f) + for row in rows: + pull_elapsed_master, create_elapsed_master, run_elapsed_master, total_elapsed_master, image_size_master, read_amount_master, read_count_master = row + pull_elapsed_compare = compare(pull_elapsed,pull_elapsed_master) + create_elapsed_compare = compare(create_elapsed, create_elapsed_master) + run_elapsed_compare = compare(run_elapsed, run_elapsed_master) + total_elapsed_compare = compare(total_elapsed, total_elapsed_master) + image_size_compare = compare(image_size, image_size_master) + read_amount_compare = compare(read_amount, read_amount_master) + read_count_compare = compare(read_count, read_count_master) + + print(f"|{filename}|{pull_elapsed_compare}|{create_elapsed_compare}|{run_elapsed_compare}|{total_elapsed_compare}|{image_size_compare}|{read_amount_compare}|{read_count_compare}|") + +def compare(data_current: str, data_master: str) -> str: + data_current = float(data_current) + data_master = float(data_master) + if abs(data_current - data_master) > DELTA + data_master * 0.05: + if data_current > data_master: + return f"{data_current}/{data_master}↑" + else: + return f"{data_current}/{data_master}↓" + return f"{data_current}/{data_master}" def main(): parser = ArgumentParser()