diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..17e588c --- /dev/null +++ b/.gitignore @@ -0,0 +1,244 @@ + +# Created by https://www.gitignore.io/api/python,pycharm,pycharm+all,pycharm+iml + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Ruby plugin and RubyMine +/.rakeTasks + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/sonarlint + +### PyCharm+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: + +# Sensitive or high-churn files: + +# Gradle: + +# CMake + +# Mongo Explorer plugin: + +## File-based project format: + +## Plugin-specific files: + +# IntelliJ + +# mpeltonen/sbt-idea plugin + +# JIRA plugin + +# Cursive Clojure plugin + +# Ruby plugin and RubyMine + +# Crashlytics plugin (for Android Studio and IntelliJ) + +### PyCharm+all Patch ### +# Ignores the whole idea folder +# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 + +.idea/ + +### PyCharm+iml ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: + +# Sensitive or high-churn files: + +# Gradle: + +# CMake + +# Mongo Explorer plugin: + +## File-based project format: + +## Plugin-specific files: + +# IntelliJ + +# mpeltonen/sbt-idea plugin + +# JIRA plugin + +# Cursive Clojure plugin + +# Ruby plugin and RubyMine + +# Crashlytics plugin (for Android Studio and IntelliJ) + +### PyCharm+iml Patch ### +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +.pytest_cache/ +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule.* + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + + +# End of https://www.gitignore.io/api/python,pycharm,pycharm+all,pycharm+iml \ No newline at end of file diff --git a/big_static_n.log b/big_static_n.log index 710e75d..761f838 100644 --- a/big_static_n.log +++ b/big_static_n.log @@ -375,5 +375,4 @@ size: 536870912, step: 8388608 and time Elapsed: 70 milliseconds size: 536870912, step: 16777216 and time Elapsed: 48 milliseconds size: 536870912, step: 33554432 and time Elapsed: 93 milliseconds size: 536870912, step: 67108864 and time Elapsed: 71 milliseconds -size: 536870912, step: 134217728 and time Elapsed: 78 milliseconds - +size: 536870912, step: 134217728 and time Elapsed: 78 milliseconds \ No newline at end of file diff --git a/heatmap.pdf b/heatmap.pdf new file mode 100644 index 0000000..6ecb942 Binary files /dev/null and b/heatmap.pdf differ diff --git a/plotter.py b/plotter.py index a09660d..a4b56f7 100644 --- a/plotter.py +++ b/plotter.py @@ -1,76 +1,84 @@ -import subprocess -import tempfile -import re -import matplotlib.pyplot as plt -from collections import defaultdict -import argparse -from math import log2 -import pandas as pd - - - -parser = argparse.ArgumentParser(description='Read data from a data file and plot this.') - -parser.add_argument('--data_file', action='store', dest='data_file', default='plot_data.txt', - help='The desired data to be plotted.') -parser.add_argument('--static_n', action='store_true', - help="Is the n variable static in the data file?") -parser.add_argument('--static_step', action='store_true', - help="Is the step variable static in the data file?") - - -args = parser.parse_args() - -data = open(args.data_file).read() - - -# d = {'static variable' : {step : time, step : time}} - - -def prep_data(static_var, data): - non_static_var = (static_var + 1) % 2 # if 0 then 1, if 1 then 0 - #non_static_var = 1 - static_var #rip :( - - lines = data.split('\n') - static_vars = set() - - data = defaultdict(dict) - - for line in lines[0:-1]: - all_vars = re.findall(r"\d+", line) - - static = int(all_vars[static_var]) - non_static = int(all_vars[non_static_var]) - time = int(all_vars[2]) - - static_vars.add(static) - data[static][non_static] = time - - return data - - - - -static_var = 0 if args.static_n else 1 -plot_data = prep_data(static_var, data) -df = pd.DataFrame(data=plot_data) -print(df) - -plt.imshow(df, cmap='hot') -plt.show() - - -#first = plot_data[list(plot_data.keys())[2]] - -#plt.plot(first[0], first[1]) - -#for static, plotting_data in plot_data.items(): -# x_axis = [log2(x) for x in plotting_data[0]] -# plt.plot(x_axis, plotting_data[1], marker="o", label = static) - - -#plt.xticks([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26], ["$log2(2^2)$", "log2(2^4)", "log2(2^6)", "log2(2^8)", "log2(2^10)", "log2(2^12)", "log2(2^14)", "log2(2^16)", "log2(2^18)", "log2(2^20)", "log2(2^22)", "log2(2^24)", "log2(2^26)"]) -#plt.legend(loc=1, borderaxespad=0.) -#plt.ylabel('time/ms') -#plt.xlabel('log(step)') -#plt.show() +import math +import subprocess +import tempfile +import re +import matplotlib.pyplot as plt +from collections import defaultdict +import argparse +from math import log2 +import pandas as pd +import seaborn as sns + + +parser = argparse.ArgumentParser(description='Read data from a data file and plot this.') + +parser.add_argument('--data_file', action='store', dest='data_file', default='plot_data.txt', + help='The desired data to be plotted.') +parser.add_argument('--static_n', action='store_true', + help="Is the n variable static in the data file?") +parser.add_argument('--static_step', action='store_true', + help="Is the step variable static in the data file?") + + +args = parser.parse_args() + +data = open(args.data_file).read() + + +# d = {'static variable' : {step : time, step : time}} + + +def prep_data(static_var, data): + non_static_var = (static_var + 1) % 2 # if 0 then 1, if 1 then 0 + #non_static_var = 1 - static_var #rip :( + + lines = data.split('\n') + static_vars = set() + + data = defaultdict(dict) + + for line in lines[0:-1]: + all_vars = re.findall(r"\d+", line) + + static = int(all_vars[static_var]) + non_static = int(all_vars[non_static_var]) + time = int(all_vars[2]) + + static_vars.add(static) + data[static][non_static] = time + + return data + + + + +static_var = 0 if args.static_n else 1 +plot_data = prep_data(static_var, data) +df = pd.DataFrame(data=plot_data) +print(df) + +hm = sns.heatmap(df, annot=False, square=False, cmap=sns.cm.rocket_r) +hm.invert_yaxis() + +# fix xtics +locs, labels = plt.xticks() +plt.xticks(locs, [f"$2^{{{int(math.log2(int(i.get_text())))}}}$" for i in labels]) +locs, labels = plt.yticks() +plt.yticks(locs, [f"$2^{{{int(math.log2(int(i.get_text())))}}}$" for i in labels]) + +plt.show() + +#first = plot_data[list(plot_data.keys())[2]] + +#plt.plot(first[0], first[1]) + +#for static, plotting_data in plot_data.items(): +# x_axis = [log2(x) for x in plotting_data[0]] +# plt.plot(x_axis, plotting_data[1], marker="o", label = static) + + +#plt.xticks([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26], ["$log2(2^2)$", "log2(2^4)", "log2(2^6)", "log2(2^8)", "log2(2^10)", "log2(2^12)", "log2(2^14)", "log2(2^16)", "log2(2^18)", "log2(2^20)", "log2(2^22)", "log2(2^24)", "log2(2^26)"]) +#plt.legend(loc=1, borderaxespad=0.) +#plt.ylabel('time/ms') +#plt.xlabel('log(step)') +#plt.show()