Skip to content

Commit

Permalink
misc: make benchmark summary more clear
Browse files Browse the repository at this point in the history
Signed-off-by: Desiki-high <ding_yadong@foxmail.com>
  • Loading branch information
Desiki-high committed Apr 26, 2023
1 parent 48c44d1 commit 2cc48b4
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions misc/benchmark/benchmark_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
("nydus-filelist-prefetch-master.csv", "nydus-filelist-prefetch.csv")
]

DELTA = 1.0

class BenchmarkSummary:
def __init__(self, mode):
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 2cc48b4

Please sign in to comment.