From 49217a6217317785b2daa190510c57d5f2ad7054 Mon Sep 17 00:00:00 2001 From: k-dominik Date: Thu, 29 Aug 2024 17:40:29 +0200 Subject: [PATCH] generate results --- .github/workflows/results.yml | 25 ++++++++++++ Readme.md | 2 + Results.md.in | 24 +++++++++++ generate-results.py | 75 +++++++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 .github/workflows/results.yml create mode 100644 Results.md.in create mode 100644 generate-results.py diff --git a/.github/workflows/results.yml b/.github/workflows/results.yml new file mode 100644 index 0000000..4dfece6 --- /dev/null +++ b/.github/workflows/results.yml @@ -0,0 +1,25 @@ +name: generate results + +on: + push: + branches: [ main ] + + +jobs: + generate-results: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: pip install jinja2 pandas pytz seaborn + - run: python generate-results.py + - uses: EndBug/add-and-commit@v9 # You can change this to use a specific version. + with: + add: 'Results.md *.png' + author_name: ilastik-bot + committer_name: ilastik bot + message: '(bot) Updated results' + new_branch: results + push: 'origin results --force' diff --git a/Readme.md b/Readme.md index a5f5432..52cdf01 100644 --- a/Readme.md +++ b/Readme.md @@ -23,3 +23,5 @@ python bench-bincount.py --hostname MyCoolComputer This will add your results to the `results-unique.csv` and `results-bincount.csv` table. Please open a PR and contribute your results :) + +**--> [Link to current results](https://github.com/ilastik/unique-bincount-benchmark/blob/results/Results.md) <--** \ No newline at end of file diff --git a/Results.md.in b/Results.md.in new file mode 100644 index 0000000..c241702 --- /dev/null +++ b/Results.md.in @@ -0,0 +1,24 @@ +# Results + +generated {{ now }}, from results of {{ n_hosts }} machines + +## Unique + +### Memory usage + +![unique-memory-usage](unique-max-memory.png) + +### Time + +![unique-runningtime](unique-runningtime.png) + +## Bincount + +### Memory usage + +![bincount-memory-usage](bincount-max-memory.png) + +### Time + +![bincount-runningtime](bincount-runningtime.png) + diff --git a/generate-results.py b/generate-results.py new file mode 100644 index 0000000..2244e4b --- /dev/null +++ b/generate-results.py @@ -0,0 +1,75 @@ +import datetime +from datetime import timedelta, timezone +from pathlib import Path + +import pandas +import pytz +import seaborn as sns +from jinja2 import Template + +utctzinfo = timezone(timedelta(hours=0)) +timeformat = "%Y-%m-%dT%H:%M:%S" + + +def gen_plots(): + shape_index_mapping = { + "(512, 128, 1)": "0", # numpy.prod((512, 128, 1)), + "(1024, 512, 1)": "1", # numpy.prod((1024, 512, 1)), + "(2048, 1024, 1)": "2", # numpy.prod((2048, 1024, 1)), + "(512, 512, 32)": "3", # numpy.prod((512, 512, 32)), + "(1024, 1024, 256)": "4", # numpy.prod((1024, 1024, 256)) + } + + results_unique = pandas.read_csv("results-unique.csv", sep="\t") + + results_unique["shape_ind"] = results_unique["shape"].map(shape_index_mapping) + + p = sns.lineplot(x="shape_ind", y="t", hue="method", data=results_unique) + p.set(yscale="log") + fig = p.get_figure() + fig.savefig("unique-runningtime.png") + + p.clear() + + p = sns.lineplot(x="shape_ind", y="mem_max", hue="method", data=results_unique) + p.set(yscale="log") + fig = p.get_figure() + fig.savefig("unique-max-memory.png") + + p.clear() + + results_bincount = pandas.read_csv("results-bincount.csv", sep="\t") + + results_bincount["shape_ind"] = results_bincount["shape"].map(shape_index_mapping) + + p = sns.lineplot(x="shape_ind", y="t", hue="method", data=results_bincount) + p.set(yscale="log") + fig = p.get_figure() + fig.savefig("bincount-runningtime.png") + + p.clear() + + p = sns.lineplot(x="shape_ind", y="mem_max", hue="method", data=results_bincount) + p.set(yscale="log") + fig = p.get_figure() + fig.savefig("bincount-max-memory.png") + + p.clear() + + +def main(): + template = Template(Path("Results.md.in").read_text()) + gen_plots() + n_hosts = len(pandas.read_csv("results-unique.csv", sep="\t")["host"].unique()) + + tz = pytz.timezone("Europe/Berlin") + now = datetime.datetime.now(tz) + + # render + rendered = template.render(now=now.strftime(timeformat), n_hosts=n_hosts) + + Path("Results.md").write_text(rendered) + + +if __name__ == "__main__": + main()