diff --git a/LW1/README.md b/LW1/README.md new file mode 100644 index 0000000..47b24bc --- /dev/null +++ b/LW1/README.md @@ -0,0 +1,13 @@ +# Results +## Function execution time measurement +|Interpitator | Pure Python without type annotations | Pure Python with type annotations | Python + numpy| +| --- | --- | --- | --- | +|CPython 3.9 | 0.255727898 s | 0.250940687 s | 0.333585421 s| +|CPython 3.11 | 0.178182069 s | 0.18051334 s | 0.312025812 s | +|Latest PyPy for Python 3.9 | 0.039385466 s | 0.312025812 s | 1.51180428 s | +## Measuring the execution time of a function along with running the script and interpreter +|Interpitator | Pure Python without type annotations | Pure Python with type annotations | Python + numpy | +| --- | --- | --- | --- | +|CPython 3.9 | **real**: 0m0,260s; **user**: 0m0,260s; **sys**: 0m0,000s | **real**: 0m0,262s; **user**: 0m0,262s; **sys**: 0m0,000s | **real**: 0m0,458s; **user**: 0m0,644s; **sys**: 0m0,712s | +|CPython 3.11 | **real**: 0m0,191s; **user**: 0m0,191s; **sys**: 0m0,000s | **real**: 0m0,191s; **user**: 0m0,190s; **sys**: 0m0,000s | **real**: 0m0,426s; **user**: 0m0,533s; **sys**: 0m0,794s | +|Latest PyPy for Python 3.9 | **real**: 0m0,065s; **user**: 0m0,065s; **sys**: 0m0,000s | **real**: 0m0,064s; **user**: 0m0,064s; **sys**: 0m0,000s | **real**: 0m1,863s; **user**: 0m2,072s; **sys**: 0m0,687s | diff --git a/LW1/python_and_numpy.py b/LW1/python_and_numpy.py new file mode 100644 index 0000000..8d36c89 --- /dev/null +++ b/LW1/python_and_numpy.py @@ -0,0 +1,24 @@ +import time +import numpy as np + +def mandelbrot(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 + +tic = time.perf_counter_ns() +image = mandelbrot() +toc = time.perf_counter_ns() +print((toc - tic)/1_000_000_000, "s") \ No newline at end of file diff --git a/LW1/with_annotation.py b/LW1/with_annotation.py new file mode 100644 index 0000000..b5297a1 --- /dev/null +++ b/LW1/with_annotation.py @@ -0,0 +1,28 @@ +import time +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 + +def mandelbrot(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 + +tic = time.perf_counter_ns() +image = mandelbrot() +toc = time.perf_counter_ns() +print((toc - tic)/1_000_000_000, "s") \ No newline at end of file diff --git a/LW1/without_annotation.py b/LW1/without_annotation.py new file mode 100644 index 0000000..16e570c --- /dev/null +++ b/LW1/without_annotation.py @@ -0,0 +1,27 @@ +import time +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 + +def mandelbrot(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 + +tic = time.perf_counter_ns() +image = mandelbrot() +toc = time.perf_counter_ns() +print((toc - tic)/1_000_000_000, "s") \ No newline at end of file diff --git a/scada_system/README.md b/scada_system/README.md index df71492..e587eaf 100644 --- a/scada_system/README.md +++ b/scada_system/README.md @@ -15,7 +15,7 @@ pip install -r requirements.txt pip install -e . ``` -4. To generate documentation in HTML format, you need to run the following commands: +5. To generate documentation in HTML format, you need to run the following commands: ``` cd ./docs make html