Commit 37811067 authored by Florian Fischer's avatar Florian Fischer
Browse files

add script to parse the server's emper stats

parent c7e88eb1
.PHONY: all clean check fotmat check-format check-pylint clean-emper clean-emper-client eval servers clients
PYTHONFILES := eval.py plot.py find_best.py parse_results.py plot_tail_latency.py plot_utils.py bench/*.py
PYTHONFILES := eval.py plot.py find_best.py parse_results.py parse_server_stats.py plot_tail_latency.py plot_utils.py bench/*.py
all: servers clients
......
#!/usr/bin/env python3
import argparse
import sys
from pathlib import Path
import typing as T
import numpy as np
Server = str
Run = int
RunStats = dict[str, float]
RawServerStats = list[RunStats]
ServerStatsResults = dict[Server, RawServerStats]
def collect_stats(result_dir: T.Union[Path, str]) -> ServerStatsResults:
result_dir = Path(result_dir)
impl_dirs = {d.name: d for d in result_dir.iterdir() if d.is_dir()}
results = {}
for impl, impl_dir in impl_dirs.items():
srv_d: RawServerStats = []
stat_files = impl_dir.glob('?.out')
# collect all data
for stat_path in stat_files:
run_d = {}
with open(stat_path, 'r', encoding='utf-8') as stat_file:
for line in stat_file.readlines():
try:
stat, val = line.split(': ')
run_d[stat] = float(val)
except ValueError:
continue
srv_d.append(run_d)
results[impl] = srv_d
return results
DescStats = dict[str, float]
Stats = dict[str, DescStats]
ServerStats = dict[Server, Stats]
def calculate_stats(data: ServerStatsResults, warn=False) -> ServerStats:
stats = {}
for impl, impl_d in data.items():
impl_stats = {}
for key in impl_d[0]:
values = [s[key] for s in impl_d]
cur_stats = {}
cur_stats['mean'] = np.mean(values)
cur_stats['median'] = np.median(values)
cur_stats['min'] = min(values)
cur_stats['max'] = max(values)
cur_stats['std'] = np.std(values)
if warn:
precision = cur_stats['std'] / cur_stats['mean']
if precision > 0.05:
print(('Warning: imprecise data impl:',
f' {impl}, k: {key} p: {precision*100:.5}%'),
file=sys.stderr)
impl_stats[key] = cur_stats
stats[impl] = impl_stats
return stats
def print_dataref(stats: ServerStats, variables=None, dstats=None):
for impl, impl_stats in stats.items():
keys = variables or impl_stats.keys()
for key in keys:
if not key in impl_stats:
continue
desc_stats = impl_stats[key]
dstats = dstats or desc_stats.keys()
for stat in dstats:
val = desc_stats[stat]
if stat == 'outliers':
continue
print(rf'\drefset{{{impl}/{key}/{stat}}}{{{val}}}')
def main():
parser = argparse.ArgumentParser()
parser.add_argument("result_dir")
parser.add_argument("-w",
"--warn",
help='warn about imprecise data',
action='store_true')
parser.add_argument("--desc-stats",
help="descriptive statistics to print",
nargs='*')
parser.add_argument("--variables",
help="descriptive statistics to print",
nargs='*')
args = parser.parse_args()
data = collect_stats(args.result_dir)
stats = calculate_stats(data, args.warn)
print_dataref(stats, variables=args.variables, dstats=args.desc_stats)
if __name__ == '__main__':
main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment