Skip to content

Commit

Permalink
misc: add image-size for benchmark
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 23, 2023
1 parent 7c63cf6 commit 063bd21
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
8 changes: 5 additions & 3 deletions misc/benchmark/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ def run_cmd_url_wait(self, repo, runargs):
if self.cleanup:
self.clean_up(image_ref, container_id)

return pull_elapsed, create_elapsed, run_elapsed, read_amount, read_count
# TODO : get the image size
image_size = 0
return pull_elapsed, create_elapsed, run_elapsed, image_size, read_amount, read_count

def pull_cmd(self, image_ref):
insecure_flag = "--insecure-registry" if self.insecure_registry else ""
Expand Down Expand Up @@ -253,11 +255,11 @@ def bench_image(local_registry, insecure_local_registry, image, f: TextIOWrapper
cleanup=True,
insecure_registry=insecure_local_registry,
)
pull_elapsed, create_elapsed, run_elapsed, read_amount, read_count = runner.run(bench)
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}"
line = f"{bench.name},{pull_elapsed},{create_elapsed},{run_elapsed},{total_elapsed},{read_amount},{read_count}"
line = f"{pull_elapsed},{create_elapsed},{run_elapsed},{total_elapsed},{image_size},{read_amount},{read_count}"
f.writelines(line + "\n")
f.flush()
4 changes: 1 addition & 3 deletions misc/benchmark/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def main():
# bench
start_bench(cfg, cfg["image"], mode)


def collect_metrics(cfg: dict, image: str) -> str:
"""
collect container access metrics
Expand All @@ -53,9 +54,6 @@ def start_bench(cfg: dict, image: str, mode: str):
bench oci, nydus without prefetch, nydus with all prefetch, nydus witch prefetch file list
"""
f = open(util.image_repo(image) + ".csv", "w")
csv_headers = "repo,pull_elapsed(s),create_elapsed(s),run_elapsed(s),total_elapsed(s),read_amount(MB),read_count"
f.writelines(csv_headers + "\n")
f.flush()
if mode == "oci":
util.enable_wondersphaper(cfg["bandwith"])
bench.bench_image(cfg["local_registry"], cfg["insecure_local_registry"], image, f)
Expand Down
9 changes: 4 additions & 5 deletions misc/benchmark/benchmark_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ 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) |read-amount(MB) |read-count |")
print("|:-------------|:---------------:|:-----------------:|:--------------:|:----------------:|:--------------:|:---------:|")
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:
Expand Down Expand Up @@ -81,10 +81,9 @@ def print_csv(file: str):
with open(file, 'r', newline='') as f:
filename = file.rstrip(".csv")
rows = csv.reader(f)
next(rows) # we don't need header
for row in rows:
_, pull_elapsed, create_elapsed, run_elapsed, total_elapsed, read_amount, read_count = row
print(f"|{filename}|{pull_elapsed}|{create_elapsed}|{run_elapsed}|{total_elapsed}|{read_amount}|{read_count}|")
pull_elapsed, create_elapsed, run_elapsed, total_elapsed, image_size, read_amount, read_count = row
print(f"|{filename}|{pull_elapsed}|{create_elapsed}|{run_elapsed}|{total_elapsed}|{image_size}|{read_amount}|{read_count}|")


def main():
Expand Down

0 comments on commit 063bd21

Please sign in to comment.