constellation/.github/actions/e2e_benchmark/evaluate/evaluators/knb.py
Moritz Eckert 0481c039f7 ci: add kubestr and knb based e2e_benchmark action
Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
2023-03-03 09:43:49 +01:00

26 lines
783 B
Python

"""Parse the knb logs.
Extracts the bandwidth for sending and receiving,
from k8s-bench-suite network benchmarks.
"""
import json
from typing import Dict
def evaluate(log_path) -> Dict[str, Dict[str, float]]:
with open(log_path) as f:
knb = json.load(f)
if not knb:
raise Exception(
f"Error: Empty knb log {log_path}?"
)
data = knb['data']
result = {'pod2pod': {}, 'pod2svc': {}}
result['pod2pod']['tcp_bw_mbit'] = float(data['pod2pod']['tcp']['bandwidth'])
result['pod2pod']['upd_bw_mbit'] = float(data['pod2pod']['udp']['bandwidth'])
result['pod2svc']['tcp_bw_mbit'] = float(data['pod2svc']['tcp']['bandwidth'])
result['pod2svc']['upd_bw_mbit'] = float(data['pod2svc']['udp']['bandwidth'])
return result