implementing results csv and local to local

This commit is contained in:
alex
2023-09-06 15:27:26 +02:00
parent 02cfd51fd9
commit afc6c5f3cf
3 changed files with 94 additions and 34 deletions

36
benchmark.py Normal file
View File

@@ -0,0 +1,36 @@
# copyright: Canonical
"Run the bench cases (remote to local)."
import datetime
import subprocess
from pathlib import Path
from loguru import logger as log
def run_single_bench(
runnum,
test_case,
files_type,
source,
target,
results,
):
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.add([runnum, test_case, files_type, speed, time.total_seconds(), size_MB])