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..22ed802 --- /dev/null +++ b/benchmark-time.svg @@ -0,0 +1,1461 @@ + + + + + + + + 2024-08-06T07:04:37.806123 + image/svg+xml + + + Matplotlib v3.9.0, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/benchmark-addr2line.sh b/scripts/benchmark-addr2line.sh index 39a1d23..8d9ad41 100755 --- a/scripts/benchmark-addr2line.sh +++ b/scripts/benchmark-addr2line.sh @@ -9,7 +9,8 @@ mkdir -p $WORKDIR benchmark() { $ADDR2LINE_BINARY --all -a -e $1 | grep 0x | shuf --random-source=<(yes 123456789) | head -n $2 > $SYMBOLS_PATH BINARY_NAME=`basename -s .debug $1` - echo "=== Running benchmark for $BINARY_NAME (`du -hs $1 | cut -f1`, $2 symbol queries) ===" + BINARY_SIZE=`du -hs $1 | cut -f1` + echo "=== Running benchmark for $BINARY_NAME ===" hyperfine \ --style=color \ @@ -22,6 +23,8 @@ benchmark() { --export-json="$WORKDIR/benchmark-$BINARY_NAME.json" \ -L input $BINARY_NAME \ -L tool $ADDR2LINE_BINARY,/usr/bin/llvm-addr2line,/usr/bin/addr2line,/usr/bin/eu-addr2line \ + -L size $BINARY_SIZE \ + -L symbol_queries $2 \ "{tool} -af -e $1 < $SYMBOLS_PATH" } diff --git a/scripts/benchmark-plot.py b/scripts/benchmark-plot.py index 12d0685..99f204e 100755 --- a/scripts/benchmark-plot.py +++ b/scripts/benchmark-plot.py @@ -1,15 +1,13 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import argparse import glob import json import matplotlib.pyplot as plt -import sys +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,21 +15,32 @@ 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]) - inputs.append(results[0]["parameters"]["input"]) -data = map(list, zip(*data)) -for (times, command) in zip(data, commands): - plt.plot(inputs, times, label=command) + input = results[0]["parameters"]["input"] + binary_size = results[0]["parameters"]["size"] + symbol_queries = results[0]["parameters"]["symbol_queries"] + inputs.append(f"{input}\n({binary_size}B,\n{symbol_queries} queries)") + +data = np.transpose(data) + +x = np.arange(len(inputs)) # the label locations +width = 0.2 # the width of the bars + +fig, ax = plt.subplots(layout="constrained") +for i, command in enumerate(commands): + offset = width * (i + 1) + rects = ax.bar(x + offset, data[i], width, label=command) + +ax.set_xticks(x + 0.5, inputs) plt.title("addr2line runtime") plt.xlabel("Input") plt.ylabel("Time [s]") -plt.ylim(0, None) plt.legend(title="Tool") if args.output: