Skip to content
Myr

Add a simple script to show advanced statistics

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by sharkdp · parent 0ba8a20 · Browse files · 1 file+34 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+34 added−0 removed

  • other:+34 added−0 removed

1 file+34 added−0 removed

added:scripts/advanced_statistics.py+34 added
1#!/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()