implementing results csv and local to local
This commit is contained in:
69
run.py
69
run.py
@@ -1,46 +1,41 @@
|
||||
"Run the bench cases."
|
||||
# copyright: Canonical
|
||||
import datetime
|
||||
"Run the bench cases (remote to local)."
|
||||
import json
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from loguru import logger as log
|
||||
import click
|
||||
|
||||
from benchmark import run_single_bench
|
||||
from definitions import BENCH_DIR_NAMES, CEPH_ROOT, INST_STO_ROOT, REMOTE_INST_STO_ROOT, SERV_URL
|
||||
from results_tools import Results
|
||||
|
||||
RESULTS = [["Run num", "test_case", "files", "MB/s", "time", "full size"]]
|
||||
results = Results()
|
||||
|
||||
|
||||
def run_single_bench(
|
||||
runnum,
|
||||
test_case,
|
||||
files_type,
|
||||
source,
|
||||
target,
|
||||
):
|
||||
log.info(f"Syncing {runnum} {test_case} {files_type}")
|
||||
start = datetime.datetime.now()
|
||||
subprocess.run(
|
||||
[
|
||||
"rsync",
|
||||
"-a",
|
||||
f"{source}",
|
||||
f"{target}",
|
||||
],
|
||||
capture_output=True,
|
||||
# shell=True,
|
||||
)
|
||||
time = datetime.datetime.now() - start
|
||||
size = sum(f.stat().st_size for f in Path(target).glob("**/*") if f.is_file())
|
||||
size_MB = size / 1000 / 1000 / 8
|
||||
speed = size_MB / time.total_seconds()
|
||||
log.info(f"{files_type} - {speed} MB/s")
|
||||
subprocess.run(["rm", "-rf", target])
|
||||
RESULTS.append([runnum, test_case, files_type, speed, time.total_seconds(), size_MB])
|
||||
@click.group()
|
||||
def cli():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@cli.command()
|
||||
def local():
|
||||
click.echo("Running locally")
|
||||
for runnum in range(50):
|
||||
for files_type in BENCH_DIR_NAMES:
|
||||
test_case = "Distant-InsSto to InsSto"
|
||||
source = f"{INST_STO_ROOT}/{files_type}"
|
||||
target = CEPH_ROOT + files_type
|
||||
run_single_bench(
|
||||
runnum,
|
||||
test_case,
|
||||
files_type,
|
||||
source,
|
||||
target,
|
||||
)
|
||||
|
||||
|
||||
@cli.command()
|
||||
def distant():
|
||||
click.echo("Running distant to local")
|
||||
for runnum in range(50):
|
||||
for files_type in BENCH_DIR_NAMES:
|
||||
test_case = "Distant-InsSto to InsSto"
|
||||
@@ -63,6 +58,12 @@ if __name__ == "__main__":
|
||||
files_type,
|
||||
source,
|
||||
target,
|
||||
results,
|
||||
)
|
||||
|
||||
json.dump(RESULTS, open("results.json", "w"))
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
|
||||
json.dump(results.result_list, open("results.json", "w"))
|
||||
results.save_to_csv()
|
||||
|
||||
Reference in New Issue
Block a user