advanced_statistics.py
This file
Path
scripts/advanced_statistics.py
38 lines · 1.1 KiB · Python
Last changed by
Not known.
History of this fileTake it
1#!/usr/bin/env 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(" min: {:8.3f} s".format(np.min(ts)))30 print(" max: {:8.3f} s".format(np.max(ts)))31 print()32 print(" percentiles:")33 print(" P_05 .. P_95: {:.3f} s .. {:.3f} s".format(p05, p95))34 print(35 " P_25 .. P_75: {:.3f} s .. {:.3f} s "36 "(IQR = {:.3f} s)".format(p25, p75, iqr)37 )38 print()