Skip to content
Myr

advanced_statistics.py

This file

Path

scripts/advanced_statistics.py

39 lines · 1.1 KiB · Python

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than d9418e0 point at it.

Use raw executor by default, skip intermediate shellDavid Peterbefore adoptiond9418e0

lines 1–25why, one step back
1#!/usr/bin/env python
23import 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))

Add number of runs to advanced_statistics.pyDavid Peterbefore adoptionbcd3705

line 26why, one step back
26 print(" runs: {:8d}".format(len(ts)))

Use raw executor by default, skip intermediate shellDavid Peterbefore adoptiond9418e0

lines 27–39why, one step back
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()