Skip to content

Commit

Permalink
normalized memory in plots
Browse files Browse the repository at this point in the history
  • Loading branch information
k-dominik committed Sep 4, 2024
1 parent 8e10074 commit 8faf757
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install jinja2 pandas pytz seaborn
- run: pip install jinja2 pandas pytz seaborn pint
- run: python generate-results.py
- uses: EndBug/add-and-commit@v9 # You can change this to use a specific version.
with:
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ dependencies:
- ipython
- ipdb
- rich
- pint
- numba
38 changes: 25 additions & 13 deletions generate-results.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,46 @@
from datetime import timedelta, timezone
from pathlib import Path

import numpy
import pandas
import pytz
import seaborn as sns
from jinja2 import Template
from pint import UnitRegistry

ureg = UnitRegistry()

x = ureg.Quantity(1, "bytes")


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))
"(512, 128, 1)": numpy.prod((512, 128, 1)) * 4 * ureg.bytes,
"(1024, 512, 1)": numpy.prod((1024, 512, 1)) * 4 * ureg.bytes,
"(2048, 1024, 1)": numpy.prod((2048, 1024, 1)) * 4 * ureg.bytes,
"(512, 512, 32)": numpy.prod((512, 512, 32)) * 4 * ureg.bytes,
"(1024, 1024, 256)": numpy.prod((1024, 1024, 256)) * 4 * ureg.bytes,
}

results_unique = pandas.read_csv("results-unique.csv", sep="\t")

results_unique["shape_ind"] = results_unique["shape"].map(shape_index_mapping)
results_unique["shape_ind_r"] = results_unique["shape_ind"].apply(lambda x: format(x.to_compact(), "~.0f"))
results_unique["memory_ref"] = results_unique["shape_ind"].apply(lambda x: x.magnitude)
results_unique["mem_max_norm"] = results_unique["mem_max"] / results_unique["memory_ref"]

p = sns.lineplot(x="shape_ind", y="t", hue="method", data=results_unique)
p = sns.lineplot(x="shape_ind_r", 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 = sns.lineplot(x="shape_ind_r", y="mem_max_norm", hue="method", data=results_unique)
p.set(yscale="log")
fig = p.get_figure()
fig.savefig("unique-max-memory.png")
Expand Down Expand Up @@ -70,26 +80,29 @@ def normalize(row):

results_unique["normalized_t"] = results_unique.apply(normalize, axis=1)

p = sns.lineplot(x="shape_ind", y="normalized_t", hue="method", data=results_unique)
p = sns.lineplot(x="shape_ind_r", y="normalized_t", hue="method", data=results_unique)
p.set(yscale="log")
fig = p.get_figure()
fig.savefig("unique-runningtime-normalized.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)
results_bincount["shape_ind_r"] = results_bincount["shape_ind"].apply(lambda x: format(x.to_compact(), "~.0f"))
results_bincount["memory_ref"] = results_bincount["shape_ind"].apply(lambda x: x.magnitude)
results_bincount["mem_max_norm"] = results_bincount["mem_max"] / results_bincount["memory_ref"]

p = sns.lineplot(x="shape_ind_r", 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 = sns.lineplot(x="shape_ind_r", y="mem_max_norm", hue="method", data=results_bincount)
p.set(yscale="log")
fig = p.get_figure()
fig.savefig("bincount-max-memory.png")
Expand Down Expand Up @@ -128,15 +141,14 @@ def normalize(row):

results_bincount["normalized_t"] = results_bincount.apply(normalize, axis=1)

p = sns.lineplot(x="shape_ind", y="normalized_t", hue="method", data=results_bincount)
p = sns.lineplot(x="shape_ind_r", y="normalized_t", hue="method", data=results_bincount)
p.set(yscale="log")
fig = p.get_figure()
fig.savefig("bincount-runningtime-normalized.png")

p.clear()



def main():
template = Template(Path("Results.md.in").read_text())
gen_plots()
Expand Down

0 comments on commit 8faf757

Please sign in to comment.