From 2f51d22e4d6e2d3d94d6eb8de7eb4e7d39b1b25d Mon Sep 17 00:00:00 2001 From: sharkdp Date: Wed, 12 Dec 2018 20:27:14 +0100 Subject: [PATCH] Add a simple script to show advanced statistics --- scripts/advanced_statistics.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 scripts/advanced_statistics.py diff --git a/scripts/advanced_statistics.py b/scripts/advanced_statistics.py new file mode 100755 index 0000000..6b9d702 --- /dev/null +++ b/scripts/advanced_statistics.py @@ -0,0 +1,34 @@ +#!/usr/bin/python + +import argparse +import json +import numpy as np + +parser = argparse.ArgumentParser() +parser.add_argument("file", help="JSON file with benchmark results") +args = parser.parse_args() + +with open(args.file) as f: + results = json.load(f)["results"] + +commands = [b["command"] for b in results] +times = [b["times"] for b in results] + +for command, ts in zip(commands, times): + p05 = np.percentile(ts, 5) + p25 = np.percentile(ts, 25) + p75 = np.percentile(ts, 75) + p95 = np.percentile(ts, 95) + + iqr = p75 - p25 + + print("Command '{}'".format(command)) + print(" mean: {:8.3f} s".format(np.mean(ts))) + print(" stddev: {:8.3f} s".format(np.std(ts, ddof=1))) + print(" median: {:8.3f} s".format(np.median(ts))) + print() + print(" percentiles:") + print(" P_05 .. P_95: {:.3f} s .. {:.3f} s".format(p05, p95)) + print(" P_25 .. P_75: {:.3f} s .. {:.3f} s " + "(IQR = {:.3f} s)".format(p25, p75, iqr)) + print()