advanced_statistics.py
This file
Path
scripts/advanced_statistics.py
34 lines · 981 bytes · Python
Last changed by
Add a simple script to show advanced statisticssharkdpbefore adoption2f51d22
History of this fileTake it
Add a simple script to show advanced statisticssharkdpbefore adoption2f51d22
lines 1–34why, one step back1#!/usr/bin/python23import argparse4import json5import numpy as np67parser = argparse.ArgumentParser()8parser.add_argument("file", help="JSON file with benchmark results")9args = parser.parse_args()1011with open(args.file) as f:12 results = json.load(f)["results"]1314commands = [b["command"] for b in results]15times = [b["times"] for b in results]1617for command, ts in zip(commands, times):18 p05 = np.percentile(ts, 5)19 p25 = np.percentile(ts, 25)20 p75 = np.percentile(ts, 75)21 p95 = np.percentile(ts, 95)2223 iqr = p75 - p252425 print("Command '{}'".format(command))26 print(" mean: {:8.3f} s".format(np.mean(ts)))27 print(" stddev: {:8.3f} s".format(np.std(ts, ddof=1)))28 print(" median: {:8.3f} s".format(np.median(ts)))29 print()30 print(" percentiles:")31 print(" P_05 .. P_95: {:.3f} s .. {:.3f} s".format(p05, p95))32 print(" P_25 .. P_75: {:.3f} s .. {:.3f} s "33 "(IQR = {:.3f} s)".format(p25, p75, iqr))34 print()