diff options
author | Serpent7776 <Serpent7776@gmail.com> | 2024-03-13 21:33:15 +0100 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2024-03-14 08:26:35 +0100 |
commit | 51d056a3de9a809c60c645497ec7f4073b8b6108 (patch) | |
tree | 8530ddb229a20e997c2c606cfe488b1c55ba955e | |
parent | 836d1730b5fe0725d03c629952539d9e3fab4cdb (diff) |
Add --sort-by option
-rwxr-xr-x | scripts/plot_whisker.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/scripts/plot_whisker.py b/scripts/plot_whisker.py index ef34597..2dbd002 100755 --- a/scripts/plot_whisker.py +++ b/scripts/plot_whisker.py @@ -15,6 +15,7 @@ import matplotlib.pyplot as plt 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" ) @@ -32,11 +33,12 @@ 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] +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) |