Skip to content

Commit

Permalink
fix result rewriter
Browse files Browse the repository at this point in the history
Signed-off-by: Aki Abramowski <[email protected]>
  • Loading branch information
abraakie committed Apr 22, 2024
1 parent ae94e98 commit c0d4a64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Benchmark
on:
schedule:
- cron: "*/30 * * * *"
#schedule:
# - cron: "*/30 * * * *"
workflow_dispatch:
pull_request:
branches:
Expand Down
39 changes: 6 additions & 33 deletions benchmark/result_rewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,27 @@ def create_entry(name, value, unit):
return entry


def read_metric(metric):
task = metric.get("task")
throughput = metric.get("throughput")
latency = metric.get("latency")
service_time = metric.get("service_time")
client_processing_time = metric.get("client_processing_time")
processing_time = metric.get("processing_time")
error_rate = metric.get("error_rate")
return [
create_entry(f"{task} throughput mean", 1 % throughput.get("mean"), "s/ops"),
create_entry(f"{task} latency mean", latency.get("mean"), "ms"),
create_entry(f"{task} error rate", error_rate * 100, "%")
]


def rewrite_results(src_file):
try:
result = []
with open(src_file, 'r') as f:
src = json.load(f)
results = src.get("results")
metrics = results.get("op_metrics")
for metric in metrics:
result.extend(read_metric(metric))
return result
except Exception as e:
print(f"Failed to rewrite benchmark results: {e}")
sys.exit(1)


def rewrite_csv(src_file):
try:
result = []
with open(src_file, 'r', newline='') as f:
reader = csv.reader(f)
with open(src_file, 'r', newline='') as file:
reader = csv.reader(file)
next(reader)
for row in reader:
if row[1] == "" or row[1] is None:
continue
else:
name = f"{row[0]} {row[1]}"
if name.startswith("Min") or name.startswith("Max") or name.startswith("Median"):
if name.startswith("Min") or name.startswith("Max") or name.startswith("Median") or not name.startswith("50th"):
continue
unit = row[3]
value = float(row[2])
if unit == "ops/s":
value = 1 / value
unit = "s/ops"
elif unit == "docs/s":
value = 1 / value
unit = "s/docs"
entry = create_entry(name, value, unit)
result.append(entry)
return result
Expand Down

0 comments on commit c0d4a64

Please sign in to comment.