mirror of
https://github.com/sharkdp/hyperfine.git
synced 2024-09-11 14:07:02 +03:00
Nicer whiskers plot
- add missing encoding when opening input file - add labels to x ticks, rotated by 45 deg - sort data by median, ascending
This commit is contained in:
parent
c7be935da3
commit
c87eba2713
@ -24,7 +24,7 @@ parser.add_argument(
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.file) as f:
|
||||
with open(args.file, encoding='utf-8') as f:
|
||||
results = json.load(f)["results"]
|
||||
|
||||
if args.labels:
|
||||
@ -32,6 +32,11 @@ if args.labels:
|
||||
else:
|
||||
labels = [b["command"] for b in results]
|
||||
times = [b["times"] for b in results]
|
||||
medians = [b["median"] for b in results]
|
||||
|
||||
indices = sorted(range(len(labels)), key=lambda k: medians[k])
|
||||
labels = [labels[i] for i in indices]
|
||||
times = [times[i] for i in indices]
|
||||
|
||||
boxplot = plt.boxplot(times, vert=True, patch_artist=True)
|
||||
cmap = plt.get_cmap("rainbow")
|
||||
@ -45,6 +50,7 @@ if args.title:
|
||||
plt.legend(handles=boxplot["boxes"], labels=labels, loc="best", fontsize="medium")
|
||||
plt.ylabel("Time [s]")
|
||||
plt.ylim(0, None)
|
||||
plt.xticks(list(range(1, len(labels)+1)), labels, rotation=45)
|
||||
if args.output:
|
||||
plt.savefig(args.output)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user