@@ -56,7 +56,9 @@ pycompile -i your_python_files --clean-source --engine nuitka
56
56
By default, the [ Cython] ( https://cython.org/ ) is being used as the default
57
57
compiler.
58
58
59
- For compiling the ` examples ` use the following command:
59
+ > [ !TIP]
60
+ > For compiling the ` examples ` use the following command
61
+
60
62
``` bash
61
63
pycompile -i input_path --engine cython
62
64
```
@@ -88,26 +90,29 @@ examples
88
90
| --verbose | Increase log messages. |
89
91
| --profile_func_pattern TEXT | function name pattern for profiling defaults to ` benchmark ` |
90
92
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:
92
94
``` bash
93
95
pycompile benchmark -i src/examples -vvv
94
96
```
95
97
which by default will start a ` memory ` and a ` cpu ` benchmark, starting with
96
98
` python ` and then with ` cython ` and ` nuitka `
99
+ > [ !IMPORTANT]
97
100
> The python package must have a ` test_module.py ` because both benchmark types are invoked
98
101
> with ` pytest ` runs
99
102
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 ` .
106
110
107
111
Hence, the following structure are required for the ` benchmark ` subcommand.
108
112
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 ` .
111
116
112
117
113
118
``` text
@@ -132,36 +137,7 @@ Line # Mem usage Increment Occurrences Line Contents
132
137
``` text
133
138
46.03s call test_examples.py::test_examples
134
139
```
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
+
165
141
166
142
** CPU benchmark** using:` 3.10.9 (main, Feb 2 2023, 12:59:36) [Clang 14.0.0 (clang-1400.0.29.202)] `
167
143
``` text
@@ -178,39 +154,8 @@ Legend:
178
154
29.40s call test_examples.py::test_examples
179
155
```
180
156
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
-
211
157
![ benchmark_cython_python.gif] ( data/benchmark_cython_python.gif )
212
158
213
-
214
159
### Dry run
215
160
216
161
| Syntax | Description |
0 commit comments