Skip to content

Commit d8de490

Browse files
committed
update main readme, add sphnix dependencies for markdown support
1 parent 4292002 commit d8de490

File tree

4 files changed

+683
-166
lines changed

4 files changed

+683
-166
lines changed

Makefile

+9-1
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,16 @@ build-docs: ## Build docs
4343
clean: ## Clean temp dirs
4444
rm -rf .pytest_cache coverage.xml .mypy_cache .coverage .coverage.* htmlcov
4545

46+
docs: ## Generate docs
47+
sphinx-apidoc src --output-dir docs/source_code/ --maxdepth 1 \
48+
&& rm -rf docs/_build/* \
49+
&& sphinx-build docs docs/_build/html
50+
51+
docs-live: docs ## Start a local server to render the docs
52+
python -m http.server 8091 --directory docs/_build/html
53+
4654
.PHONY: help create-env poetry-install install-hooks check test package-install \
47-
setup-local-dev docs build-api-docs build-docs clean-hooks clean
55+
setup-local-dev docs build-api-docs build-docs clean-hooks clean docs docs-live
4856

4957
help:
5058
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

README.md

+16-71
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ pycompile -i your_python_files --clean-source --engine nuitka
5656
By default, the [Cython](https://cython.org/) is being used as the default
5757
compiler.
5858

59-
For compiling the `examples` use the following command:
59+
> [!TIP]
60+
> For compiling the `examples` use the following command
61+
6062
```bash
6163
pycompile -i input_path --engine cython
6264
```
@@ -88,26 +90,29 @@ examples
8890
| --verbose | Increase log messages. |
8991
| --profile_func_pattern TEXT | function name pattern for profiling defaults to `benchmark` |
9092

91-
For running a benchmark on the `input-path` use the following command:
93+
For running a benchmark on the `input-path` use the following command:
9294
```bash
9395
pycompile benchmark -i src/examples -vvv
9496
```
9597
which by default will start a `memory` and a `cpu` benchmark, starting with
9698
`python` and then with `cython` and `nuitka`
99+
> [!IMPORTANT]
97100
> The python package must have a `test_module.py` because both benchmark types are invoked
98101
> with `pytest` runs
99102
100-
* For **memory profiling** the script will decorate all the functions in `benchmark.py`
101-
with the `profile` decorator from `memory-profiler`. This is not optimal memory profiling,
102-
because we don't actually `profile` the function itself, instead we profile the `caller` but it's necessary
103-
if we want to `profile` also the compiled code.
104-
Use the `profile_func_pattern` to specify the function to be profiled in different module for example
105-
if `main` is the entrypoint under `main.py` use `--profile_func_pattern main`.
103+
> [!NOTE]
104+
> For **memory profiling** the script will decorate all the functions in `benchmark.py`
105+
> with the `profile` decorator from `memory-profiler`. This is not optimal memory profiling,
106+
> because we don't actually `profile` the function itself, instead we profile the `caller` but it's necessary
107+
> if we want to `profile` also the compiled code.
108+
> Use the `profile_func_pattern` to specify the function to be profiled in different module for example
109+
> if `main` is the entrypoint under `main.py` use `--profile_func_pattern main`.
106110
107111
Hence, the following structure are required for the `benchmark` subcommand.
108112

109-
* For **cpu profiling** the same approached is being used, but instead of decorating the `calling functions`
110-
it `decorates` the test cases with the `benchmark` from `pytest-benchmark`.
113+
> [NOTE]
114+
> For **cpu profiling** the same approached is being used, but instead of decorating the `calling functions`
115+
> it `decorates` the test cases with the `benchmark` from `pytest-benchmark`.
111116
112117

113118
```text
@@ -132,36 +137,7 @@ Line # Mem usage Increment Occurrences Line Contents
132137
```text
133138
46.03s call test_examples.py::test_examples
134139
```
135-
**Memory benchmark** using [cython](https://cython.org/)
136-
```text
137-
Line # Mem usage Increment Occurrences Line Contents
138-
=============================================================
139-
7 66.5 MiB 66.5 MiB 1 @profile
140-
8 def samples_benchmark():
141-
9 103.7 MiB 37.3 MiB 1 sum_of_squares()
142-
10 102.9 MiB -0.8 MiB 1 harmonic_mean()
143-
11 102.9 MiB 0.0 MiB 1 fibonacci(30)
144-
12 104.9 MiB 2.0 MiB 1 sum_numbers()
145-
13 65.6 MiB -39.3 MiB 1 sum_strings()
146-
```
147-
```text
148-
4.33s call test_examples.py::test_examples
149-
```
150-
**Memory benchmark** using [nuitka](https://nuitka.net/index.html)
151-
```text
152-
Line # Mem usage Increment Occurrences Line Contents
153-
=============================================================
154-
7 71.6 MiB 71.6 MiB 1 @profile
155-
8 def samples_benchmark():
156-
9 148.8 MiB 77.1 MiB 1 sum_of_squares()
157-
10 186.5 MiB 37.7 MiB 1 harmonic_mean()
158-
11 186.5 MiB 0.0 MiB 1 fibonacci(30)
159-
12 225.1 MiB 38.6 MiB 1 sum_numbers()
160-
13 225.1 MiB 0.0 MiB 1 sum_strings()
161-
```
162-
```text
163-
3.45s call test_examples.py::test_examples
164-
```
140+
165141

166142
**CPU benchmark** using:`3.10.9 (main, Feb 2 2023, 12:59:36) [Clang 14.0.0 (clang-1400.0.29.202)]`
167143
```text
@@ -178,39 +154,8 @@ Legend:
178154
29.40s call test_examples.py::test_examples
179155
```
180156

181-
**CPU benchmark** using [cython](https://cython.org/)
182-
```text
183-
Name (time in s) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
184-
---------------------------------------------------------------------------------------------------------
185-
test_examples 4.4198 4.6645 4.4945 0.1048 4.4340 0.1376 1;0 0.2225 5 1
186-
---------------------------------------------------------------------------------------------------------
187-
188-
Legend:
189-
Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
190-
OPS: Operations Per Second, computed as 1 / Mean
191-
===================================================================================================================
192-
31.80s call test_examples.py::test_examples
193-
```
194-
195-
**CPU benchmark** using [nuitka](https://nuitka.net/index.html)
196-
```text
197-
------------------------------------------- benchmark: 1 tests ------------------------------------------
198-
Name (time in s) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
199-
---------------------------------------------------------------------------------------------------------
200-
test_examples 3.2931 3.5091 3.4278 0.0972 3.4875 0.1571 1;0 0.2917 5 1
201-
---------------------------------------------------------------------------------------------------------
202-
203-
Legend:
204-
Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
205-
OPS: Operations Per Second, computed as 1 / Mean
206-
===================================================================================================================
207-
24.02s call test_examples.py::test_examples
208-
```
209-
210-
211157
![benchmark_cython_python.gif](data/benchmark_cython_python.gif)
212158

213-
214159
### Dry run
215160

216161
| Syntax | Description |

0 commit comments

Comments
 (0)