Skip to content

Commit

Permalink
Add --sort-by option
Browse files Browse the repository at this point in the history
  • Loading branch information
serpent7776 authored and sharkdp committed Mar 14, 2024
1 parent 836d173 commit 51d056a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scripts/plot_whisker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("file", help="JSON file with benchmark results")
parser.add_argument("--title", help="Plot Title")
parser.add_argument("--sort-by", choices=['median'], help="Sort method")
parser.add_argument(
"--labels", help="Comma-separated list of entries for the plot legend"
)
Expand All @@ -32,11 +33,12 @@
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]
if args.sort_by == 'median':
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]

plt.figure(figsize=(10, 6), constrained_layout=True)
boxplot = plt.boxplot(times, vert=True, patch_artist=True)
Expand Down

0 comments on commit 51d056a

Please sign in to comment.