From f3cf3b975e7dffda70355dc783297d077a07b2ae Mon Sep 17 00:00:00 2001 From: ilia Date: Fri, 6 Oct 2023 13:14:14 +0300 Subject: [PATCH] hw2 interpreters --- interpreters/.gitignore | 162 ++++++++++++++++++ interpreters/README.md | 24 +++ interpreters/linspace.py | 7 + interpreters/np_extended.py | 24 +++ interpreters/pure_no_types.py | 22 +++ interpreters/pure_with_types.py | 23 +++ interpreters/results/CPython-3.11.txt | 4 + interpreters/results/CPython-3.11_full.txt | 12 ++ interpreters/results/CPython-3.9.txt | 4 + interpreters/results/CPython-3.9_full.txt | 12 ++ interpreters/results/Jython_error.txt | 11 ++ interpreters/results/Jython_full.txt | 11 ++ interpreters/results/PyPy-3.9-v7.3.13.txt | 4 + .../results/PyPy-3.9-v7.3.13_full.txt | 12 ++ interpreters/table.png | Bin 0 -> 9602 bytes interpreters/test.py | 43 +++++ interpreters/test_full.sh | 12 ++ interpreters/test_full_no_types.py | 3 + interpreters/test_full_np.py | 3 + interpreters/test_full_with_types.py | 3 + 20 files changed, 396 insertions(+) create mode 100644 interpreters/.gitignore create mode 100644 interpreters/README.md create mode 100644 interpreters/linspace.py create mode 100644 interpreters/np_extended.py create mode 100644 interpreters/pure_no_types.py create mode 100644 interpreters/pure_with_types.py create mode 100644 interpreters/results/CPython-3.11.txt create mode 100644 interpreters/results/CPython-3.11_full.txt create mode 100644 interpreters/results/CPython-3.9.txt create mode 100644 interpreters/results/CPython-3.9_full.txt create mode 100644 interpreters/results/Jython_error.txt create mode 100644 interpreters/results/Jython_full.txt create mode 100644 interpreters/results/PyPy-3.9-v7.3.13.txt create mode 100644 interpreters/results/PyPy-3.9-v7.3.13_full.txt create mode 100644 interpreters/table.png create mode 100644 interpreters/test.py create mode 100644 interpreters/test_full.sh create mode 100644 interpreters/test_full_no_types.py create mode 100644 interpreters/test_full_np.py create mode 100644 interpreters/test_full_with_types.py diff --git a/interpreters/.gitignore b/interpreters/.gitignore new file mode 100644 index 0000000..fae33bc --- /dev/null +++ b/interpreters/.gitignore @@ -0,0 +1,162 @@ +builds +# Byte-compiled / optimized / DLL files +__pycache__/ +.jython_cache +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# 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/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# 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/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/interpreters/README.md b/interpreters/README.md new file mode 100644 index 0000000..6500908 --- /dev/null +++ b/interpreters/README.md @@ -0,0 +1,24 @@ +# Interpreters + +## Testing Code +Three functions tested +```python:pure_with_types.py + +``` + +```python:pure_no_types.py + +``` + +```python:np_extended.py + +``` + +## Tested interpreters +- CPython 3.9 +- CPython 3.11 +- PyPy 3.9 +- Jython + +**Table of evaluation times in seconds** +![enter image description here](table.png) diff --git a/interpreters/linspace.py b/interpreters/linspace.py new file mode 100644 index 0000000..74fd047 --- /dev/null +++ b/interpreters/linspace.py @@ -0,0 +1,7 @@ +def linspace(start, stop, n): + if n == 1: + yield stop + return + h = (stop - start) / (n - 1) + for i in range(n): + yield start + h * i diff --git a/interpreters/np_extended.py b/interpreters/np_extended.py new file mode 100644 index 0000000..2e96538 --- /dev/null +++ b/interpreters/np_extended.py @@ -0,0 +1,24 @@ +import numpy as np + +def mandelbrot_np( + pmin=-2.5, + pmax=1.5, + qmin=-2, + qmax=2, + ppoints=200, + qpoints=200, + max_iterations=300, + infinity_border=100): + image = np.zeros((ppoints, qpoints)) + + for ip, p in enumerate(np.linspace(pmin, pmax, ppoints)): + for iq, q in enumerate(np.linspace(qmin, qmax, qpoints)): + c = p + 1j * q + z = 0 + for k in range(max_iterations): + z = z ** 2 + c + if abs(z) > infinity_border: + + image[ip, iq] = 1 + break + return image diff --git a/interpreters/pure_no_types.py b/interpreters/pure_no_types.py new file mode 100644 index 0000000..d919337 --- /dev/null +++ b/interpreters/pure_no_types.py @@ -0,0 +1,22 @@ +from linspace import linspace + +def mandelbrot_no_types( + pmin=-2.5, + pmax=1.5, + qmin=-2, + qmax=2, + ppoints=200, + qpoints=200, + max_iterations=300, + infinity_border=100): + image = [[0 for i in range(qpoints)] for j in range(ppoints)] + for ip, p in enumerate(linspace(pmin, pmax, ppoints)): + for iq, q in enumerate(linspace(qmin, qmax, qpoints)): + c = p + 1j * q + z = 0 + for k in range(max_iterations): + z = z ** 2 + c + if abs(z) > infinity_border: + image[ip][iq] = 1 + break + return image diff --git a/interpreters/pure_with_types.py b/interpreters/pure_with_types.py new file mode 100644 index 0000000..9e667df --- /dev/null +++ b/interpreters/pure_with_types.py @@ -0,0 +1,23 @@ +from linspace import linspace + +def mandelbrot_with_types( + pmin: float = -2.5, + pmax: float = 1.5, + qmin: float = -2, + qmax: float = 2, + ppoints: int = 200, + qpoints: int = 200, + max_iterations: int = 300, + infinity_border: float = 100) -> list[list[int]]: + + image: list[list[int]] = [[0 for i in range(qpoints)] for j in range(ppoints)] + for ip, p in enumerate(linspace(pmin, pmax, ppoints)): + for iq, q in enumerate(linspace(qmin, qmax, qpoints)): + c: complex = p + 1j * q + z: complex = 0 + for k in range(max_iterations): + z = z ** 2 + c + if abs(z) > infinity_border: + image[ip][iq] = 1 + break + return image diff --git a/interpreters/results/CPython-3.11.txt b/interpreters/results/CPython-3.11.txt new file mode 100644 index 0000000..0480efe --- /dev/null +++ b/interpreters/results/CPython-3.11.txt @@ -0,0 +1,4 @@ +interpreter: CPython-3.11 +time in seconds: +with types no types with numpy +1.001602 1.047993 1.322597 \ No newline at end of file diff --git a/interpreters/results/CPython-3.11_full.txt b/interpreters/results/CPython-3.11_full.txt new file mode 100644 index 0000000..03cef69 --- /dev/null +++ b/interpreters/results/CPython-3.11_full.txt @@ -0,0 +1,12 @@ + +real 0m1.669s +user 0m0.012s +sys 0m0.055s + +real 0m1.197s +user 0m0.004s +sys 0m0.009s + +real 0m2.274s +user 0m0.014s +sys 0m0.000s diff --git a/interpreters/results/CPython-3.9.txt b/interpreters/results/CPython-3.9.txt new file mode 100644 index 0000000..c464600 --- /dev/null +++ b/interpreters/results/CPython-3.9.txt @@ -0,0 +1,4 @@ +interpreter: CPython-3.9 +time in seconds: +with types no types with numpy +1.377455 1.345244 1.437867 \ No newline at end of file diff --git a/interpreters/results/CPython-3.9_full.txt b/interpreters/results/CPython-3.9_full.txt new file mode 100644 index 0000000..978522a --- /dev/null +++ b/interpreters/results/CPython-3.9_full.txt @@ -0,0 +1,12 @@ + +real 0m2.180s +user 0m0.008s +sys 0m0.061s + +real 0m1.696s +user 0m0.013s +sys 0m0.000s + +real 0m2.447s +user 0m0.008s +sys 0m0.004s diff --git a/interpreters/results/Jython_error.txt b/interpreters/results/Jython_error.txt new file mode 100644 index 0000000..b9367ac --- /dev/null +++ b/interpreters/results/Jython_error.txt @@ -0,0 +1,11 @@ +Traceback (most recent call last): + File "test_full_with_types.py", line 1, in + from pure_with_types import mandelbrot_with_types + File "/mnt/c/Users/rurur/Desktop/p/python/advanced_python/advanced-python-homework-2023/interpreters/pure_with_types.py", line 4 + pmin: float = -2.5, + ^ +SyntaxError: mismatched input ':' expecting RPAREN + +real 0m5.653s +user 0m15.313s +sys 0m0.617s diff --git a/interpreters/results/Jython_full.txt b/interpreters/results/Jython_full.txt new file mode 100644 index 0000000..dff3fdf --- /dev/null +++ b/interpreters/results/Jython_full.txt @@ -0,0 +1,11 @@ +Traceback (most recent call last): + File "test_full_with_types.py", line 1, in + from pure_with_types import mandelbrot_with_types + File "/mnt/c/Users/rurur/Desktop/p/python/advanced_python/advanced-python-homework-2023/interpreters/pure_with_types.py", line 4 + pmin: float = -2.5, + ^ +SyntaxError: mismatched input ':' expecting RPAREN + +real 0m4.948s +user 0m14.826s +sys 0m0.715s diff --git a/interpreters/results/PyPy-3.9-v7.3.13.txt b/interpreters/results/PyPy-3.9-v7.3.13.txt new file mode 100644 index 0000000..b7dde11 --- /dev/null +++ b/interpreters/results/PyPy-3.9-v7.3.13.txt @@ -0,0 +1,4 @@ +interpreter: PyPy-3.9-v7.3.13 +time in seconds: +with types no types with numpy +0.099699 0.093644 3.830524 \ No newline at end of file diff --git a/interpreters/results/PyPy-3.9-v7.3.13_full.txt b/interpreters/results/PyPy-3.9-v7.3.13_full.txt new file mode 100644 index 0000000..bb72907 --- /dev/null +++ b/interpreters/results/PyPy-3.9-v7.3.13_full.txt @@ -0,0 +1,12 @@ + +real 0m5.456s +user 0m0.128s +sys 0m0.459s + +real 0m3.527s +user 0m0.107s +sys 0m0.492s + +real 0m15.416s +user 0m4.836s +sys 0m1.698s diff --git a/interpreters/table.png b/interpreters/table.png new file mode 100644 index 0000000000000000000000000000000000000000..018a99966f15ae2e86741a8970eaa3b24b82762b GIT binary patch literal 9602 zcmc(F2UJtrx-OuCs1)hFH#bds5eNj7AS%j6=|qYY=>+Kz6eLokh;#`kqHZaMBAtLh z009X_2t`Wh(g`ggYZ%5p~F3>_UE ziy6qol8%l6Mmvu_%}D#kJnE^Y{m?@!O@VafUxij_7biW8t{c(OA>n69&ZlVC%mE-< z2pt_q@Xv#O+Fdk^j!v4_%*4nl%xS|>ze1?-+3of2_w-EDCPBE?fQ7SsHx_DF&%U(f znN3u|Q5V3F z{iG55$+qXu6j`r-^Aw=2L8+X27s1UD_j+m`&b~e$!3YO>@=rZ4M)Aq9S^%ZQwn6a) zZLitw7!RdZl^K)TpR+Tc*5fGh*p`dWY|}R*CO^b&OPMe*z)e>8_0AOC3$RG1xD;yZ zF+YoKmHgjyccny|)W2Wr?A`$&|grck@=pSdS9UsqpUynJI|HLu{$EbyIiCFY@ zSHMk%z~{JNvU58eH`$&wiM;%uT2daM?odd>lTv^d%E8vP$#+p58uDRH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QqhdJenLHK5L}<6r^e(ja3bt*qs3q00g38827tB~bF!gg&6`k4T L8z$wzyN~`GjWZ!M literal 0 HcmV?d00001 diff --git a/interpreters/test.py b/interpreters/test.py new file mode 100644 index 0000000..602579b --- /dev/null +++ b/interpreters/test.py @@ -0,0 +1,43 @@ +import time +import sys +from pure_with_types import mandelbrot_with_types +from pure_no_types import mandelbrot_no_types +from np_extended import mandelbrot_np + + +def test(function): + tic = time.perf_counter_ns() + image = function() + toc = time.perf_counter_ns() + return (toc - tic) / 1e9 + +def try_func(function): + try: + time = test(function) + except Exception as e: + raise e + return time + +def main(arg): + interpreter = arg[1] + + time_with_types = "err" + time_no_types = "err" + time_np = "err" + + time_with_types = try_func(mandelbrot_with_types) + time_no_types = try_func(mandelbrot_no_types) + time_np = try_func(mandelbrot_np) + + response = f"interpreter: {interpreter}\n"\ + "time in seconds:\n"\ + "with types\tno types\twith numpy\n"\ + f"err\t{time_no_types:.6f}\t{time_np:.6f}" + # response = "{:.6f} {:.6f}".format(time_no_types, time_np) + print(response) + with open("results/{}.txt".format(interpreter), "w", encoding="utf8") as f: + f.write(response) + + +if __name__ == "__main__": + main(sys.argv) diff --git a/interpreters/test_full.sh b/interpreters/test_full.sh new file mode 100644 index 0000000..9ec5dda --- /dev/null +++ b/interpreters/test_full.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +interpreterCmd=$1; +interpreterTitle=$2; + +{ + time $interpreterCmd test_full_with_types.py && + time $interpreterCmd test_full_no_types.py && + time $interpreterCmd test_full_np.py; +} 2> results/${interpreterTitle}_full.txt; + +$interpreterCmd test.py $interpreterTitle; diff --git a/interpreters/test_full_no_types.py b/interpreters/test_full_no_types.py new file mode 100644 index 0000000..5ab5d83 --- /dev/null +++ b/interpreters/test_full_no_types.py @@ -0,0 +1,3 @@ +from pure_no_types import mandelbrot_no_types + +mandelbrot_no_types() diff --git a/interpreters/test_full_np.py b/interpreters/test_full_np.py new file mode 100644 index 0000000..16277b6 --- /dev/null +++ b/interpreters/test_full_np.py @@ -0,0 +1,3 @@ +from np_extended import mandelbrot_np + +mandelbrot_np() diff --git a/interpreters/test_full_with_types.py b/interpreters/test_full_with_types.py new file mode 100644 index 0000000..1757580 --- /dev/null +++ b/interpreters/test_full_with_types.py @@ -0,0 +1,3 @@ +from pure_with_types import mandelbrot_with_types + +mandelbrot_with_types()