diff --git a/README.md b/README.md index 666e059..74cf333 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ as `addr2line` from binutils, `eu-addr2line` from elfutils, and `llvm-addr2line` from the llvm project. Current benchmarks show a performance improvement in all cases: -![addr2line runtime](benchmark-time.png) +![addr2line runtime](benchmark-time.svg) ## License diff --git a/benchmark-time.png b/benchmark-time.png deleted file mode 100644 index 7213228..0000000 Binary files a/benchmark-time.png and /dev/null differ diff --git a/benchmark-time.svg b/benchmark-time.svg new file mode 100644 index 0000000..6025fe5 --- /dev/null +++ b/benchmark-time.svg @@ -0,0 +1,1201 @@ + + + + + + + + 2024-08-05T07:21:06.740730 + image/svg+xml + + + Matplotlib v3.9.0, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/benchmark-plot.py b/scripts/benchmark-plot.py index 12d0685..f09e459 100755 --- a/scripts/benchmark-plot.py +++ b/scripts/benchmark-plot.py @@ -1,15 +1,14 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import argparse import glob import json import matplotlib.pyplot as plt -import sys +import statistics +import numpy as np parser = argparse.ArgumentParser() -parser.add_argument( - "-o", "--output", help="Save image to the given filename." -) +parser.add_argument("-o", "--output", help="Save image to the given filename.") args = parser.parse_args() @@ -17,22 +16,35 @@ data = [] inputs = [] -for filename in glob.glob("scripts/tmp/benchmark-*.json"): +for filename in sorted(glob.glob("scripts/tmp/benchmark-*.json")): with open(filename) as f: results = json.load(f)["results"] - commands = [b["command"] for b in results] - data.append([b["mean"] for b in results]) + if not commands: + # initialize the dictionary if empty + commands = {b["command"]: [] for b in results} + for result in results: + commands[result["command"]].append( + statistics.mean([result["mean"] for b in results]) + ) inputs.append(results[0]["parameters"]["input"]) -data = map(list, zip(*data)) -for (times, command) in zip(data, commands): - plt.plot(inputs, times, label=command) +x = np.arange(len(inputs)) # the label locations +width = 0.2 # the width of the bars +multiplier = 0 + +fig, ax = plt.subplots(layout="constrained") + +for command, times in commands.items(): + offset = width * multiplier + rects = ax.bar(x + offset, times, width, label=command) + multiplier += 1 + +ax.set_xticks(x + width, inputs) +ax.legend(title="Tool") plt.title("addr2line runtime") plt.xlabel("Input") plt.ylabel("Time [s]") -plt.ylim(0, None) -plt.legend(title="Tool") if args.output: plt.savefig(args.output)