mirror of
https://github.com/sharkdp/hyperfine.git
synced 2024-09-11 14:07:02 +03:00
Before this patch, executing directly one of these scripts, for example `./plot_hystogram.py` in a unix-like environment meant that the default system-level python would be used, regardless of an eventual activated virtualenv. This was due to the "#!/usr/bin/python" shebang. Changing it to "/usr/bin/env python" is a fairly standard practice, keeps intact the compatiblity with the system level python, and allows a user to run in a virtualenv if he wants.
39 lines
1.1 KiB
Python
Executable File
39 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env 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(" min: {:8.3f} s".format(np.min(ts)))
|
|
print(" max: {:8.3f} s".format(np.max(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()
|