advanced_statistics.py
This file
Path
scripts/advanced_statistics.py
39 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(" runs: {:8d}".format(len(ts)))27 print(" mean: {:8.3f} s".format(np.mean(ts)))28 print(" stddev: {:8.3f} s".format(np.std(ts, ddof=1)))29 print(" median: {:8.3f} s".format(np.median(ts)))30 print(" min: {:8.3f} s".format(np.min(ts)))31 print(" max: {:8.3f} s".format(np.max(ts)))32 print()33 print(" percentiles:")34 print(" P_05 .. P_95: {:.3f} s .. {:.3f} s".format(p05, p95))35 print(36 " P_25 .. P_75: {:.3f} s .. {:.3f} s "37 "(IQR = {:.3f} s)".format(p25, p75, iqr)38 )39 print()