calibre-web-companion/loadtesting/bench.py

35 lines
970 B
Python
Raw Permalink Normal View History

2020-07-17 03:48:54 +00:00
import csv
2020-07-17 04:39:00 +00:00
from rich.console import Console
from rich.table import Column, Table
import subprocess
subprocess.run(["locust"])
2020-07-17 03:48:54 +00:00
def floatify(mystring): # floatify probable floats
2020-07-17 04:39:00 +00:00
return f"{float(mystring):3.3f}"
2020-07-17 03:48:54 +00:00
2020-07-17 04:39:00 +00:00
results = dict()
2020-07-17 03:48:54 +00:00
with open("calibre_stats.csv", "r") as cfile:
reader = csv.reader(cfile, delimiter=",")
for row in reader:
2020-07-17 04:39:00 +00:00
if not len(row) or row[0] == "Type":
2020-07-17 03:48:54 +00:00
continue
2020-07-17 04:39:00 +00:00
results[row[0] + " " + row[1]] = {
"median": floatify(row[4]),
"avg": floatify(row[5]),
"min": floatify(row[6]),
"max": floatify(row[7]),
2020-07-17 03:48:54 +00:00
}
2020-07-17 04:39:00 +00:00
console = Console()
table = Table(show_header=True, header_style="bold green")
table.add_column("Action/url")
table.add_column("min")
table.add_column("avg")
table.add_column("median") # destination
table.add_column("max") # source
for k, v in results.items():
table.add_row(k, v["min"], v["avg"], v["median"], v["max"])
console.print(table)