Skip to content

Commit

Permalink
action: make benchmark 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 25, 2023
1 parent 44b70fa commit 48c44d1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
8 changes: 4 additions & 4 deletions misc/benchmark/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ def bench_image(local_registry, insecure_local_registry, image, f: TextIOWrapper
insecure_registry=insecure_local_registry,
)
pull_elapsed, create_elapsed, run_elapsed, image_size, read_amount, read_count = runner.run(bench)
total_elapsed = f"{pull_elapsed + create_elapsed + run_elapsed: .6f}"
pull_elapsed = f"{pull_elapsed: .6f}"
create_elapsed = f"{create_elapsed: .6f}"
run_elapsed = f"{run_elapsed: .6f}"
total_elapsed = f"{pull_elapsed + create_elapsed + run_elapsed: .2f}"
pull_elapsed = f"{pull_elapsed: .2f}"
create_elapsed = f"{create_elapsed: .2f}"
run_elapsed = f"{run_elapsed: .2f}"
line = f"{pull_elapsed},{create_elapsed},{run_elapsed},{total_elapsed},{image_size},{read_amount},{read_count}"
f.writelines(line + "\n")
f.flush()
41 changes: 27 additions & 14 deletions misc/benchmark/benchmark_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,11 @@

FILE_LIST_COMPARE = [
"oci.csv",
"nydus-all-prefetch-master.csv",
"nydus-all-prefetch.csv",
"zran-all-prefetch-master.csv",
"zran-all-prefetch.csv",
"nydus-no-prefetch-master.csv",
"nydus-no-prefetch.csv",
"zran-no-prefetch-master.csv",
"zran-no-prefetch.csv",
"nydus-filelist-prefetch-master.csv",
"nydus-filelist-prefetch.csv"
("nydus-all-prefetch-master.csv", "nydus-all-prefetch.csv"),
("zran-all-prefetch-master.csv", "zran-all-prefetch.csv"),
("nydus-no-prefetch-master.csv", "nydus-no-prefetch.csv"),
("zran-no-prefetch-master.csv", "zran-no-prefetch.csv"),
("nydus-filelist-prefetch-master.csv", "nydus-filelist-prefetch.csv")
]


Expand All @@ -51,20 +46,25 @@ def __init__(self, mode):

def summary(self):
self.prepare_csv()
print("| bench-result | pull-elapsed(s) | create-elapsed(s) | run-elapsed(s) | total-elapsed(s) | image-size(MB) | read-amount(MB) | read-count |")
print("|:-------------|:---------------:|:-----------------:|:--------------:|:----------------:|:--------------:|:---------------:|:----------:|")
if self.mode == "benchmark-result":
self.print_csv_result()
else:
self.print_csv_compare()

def print_csv_result(self):
print("| bench-result | pull(s) | create(s) | run(s) | total(s) | size(MB) | read-amount(MB) | read-count |")
print("|:-------------|:-------:|:---------:|:------:|:--------:|:--------:|:---------------:|:----------:|")
for file in FILE_LIST:
print_csv(file)

def print_csv_compare(self):
for file in FILE_LIST_COMPARE:
print_csv(file)
print("| bench-result(current vs master) | pull(s) | create(s) | run(s) | total(s) | size(MB) | read-amount(MB) | read-count |")
print("|:--------------------------------|:-------:|:---------:|:------:|:--------:|:--------:|:---------------:|:----------:|")
for item in FILE_LIST_COMPARE:
if isinstance(item, str):
print_csv(item)
else:
print_compare(item[0], item[1])

def prepare_csv(self):
"""
Expand All @@ -86,6 +86,19 @@ def print_csv(file: str):
print(f"|{filename}|{pull_elapsed}|{create_elapsed}|{run_elapsed}|{total_elapsed}|{image_size}|{read_amount}|{read_count}|")


def print_compare(file_master: str, file: str):
with open(file, 'r', newline='') as f:
filename = file.rstrip(".csv")
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}|")


def main():
parser = ArgumentParser()
parser.add_argument(
Expand Down

0 comments on commit 48c44d1

Please sign in to comment.