Skip to content

Commit 7968d94

Browse files
Add benchmark histogram option, add benchmark info to contributing
1 parent 47f3087 commit 7968d94

File tree

6 files changed

+79
-6
lines changed

6 files changed

+79
-6
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ __pycache__/
4141

4242
# Jupyter Notebook
4343
.ipynb_checkpoints
44+
45+
# benchmark results
46+
.benchmarks

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,22 @@ nox --session=tests
121121
Unit tests are located in the _tests_ directory, and are written using the [pytest]
122122
testing framework.
123123

124+
### Benchmarks
125+
126+
If the code you are modifying may affect the performance of `sectionproperties`, it is
127+
recommended that you run the benchmarking tests to verify the performance before and
128+
after your changes. There are three different benchmarking suites: `geometry`, `meshing`
129+
and `analysis`. These can be run like this:
130+
131+
```shell
132+
poetry run pytest -m benchmark_geom
133+
poetry run pytest -m benchmark_mesh
134+
poetry run pytest -m benchmark_analysis
135+
```
136+
137+
Note that a plot of the results can be generated by adding the `--benchmark-histogram`
138+
option to the above commands.
139+
124140
[pytest]: https://pytest.readthedocs.io/
125141

126142
## How to submit changes

docs/contributing.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,23 @@ this:
129129
Unit tests are located in the *tests* directory, and are written using
130130
the `pytest <https://pytest.readthedocs.io/>`__ testing framework.
131131

132+
Benchmarks
133+
^^^^^^^^^^
134+
135+
If the code you are modifying may affect the performance of ``sectionproperties``, it is
136+
recommended that you run the benchmarking tests to verify the performance before and
137+
after your changes. There are three different benchmarking suites: ``geometry``,
138+
``meshing`` and ``analysis``. These can be run like this:
139+
140+
.. code:: shell
141+
142+
poetry run pytest -m benchmark_geom
143+
poetry run pytest -m benchmark_mesh
144+
poetry run pytest -m benchmark_analysis
145+
146+
Note that a plot of the results can be generated by adding the ``--benchmark-histogram``
147+
option to the above commands.
148+
132149
How to submit changes
133150
---------------------
134151

poetry.lock

Lines changed: 31 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pre-commit = "^3.4.0"
8282
pre-commit-hooks = "^4.5.0"
8383
Pygments = "^2.16.1"
8484
pytest = "^7.4.2"
85-
pytest-benchmark = "^4.0.0"
85+
pytest-benchmark = { extras = ["histogram"], version = "^4.0.0" }
8686
pytest-check = "^2.2.2"
8787
pyupgrade = "^3.15.0"
8888
sphinx = "^7.2.6"

tests/benchmarks/conftest.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ def chs_geom() -> Geometry:
7373
def concrete_column_with_hole(concrete, steel) -> Callable:
7474
"""Creates a concrete column with a hole at its centre.
7575
76-
Return:
77-
Geometry
76+
Args:
77+
concrete: Concrete material
78+
steel: Steel material
79+
80+
Returns:
81+
Generator function
7882
"""
7983

8084
def _generate_geom() -> Geometry:
@@ -100,7 +104,11 @@ def _generate_geom() -> Geometry:
100104

101105
@pytest.fixture
102106
def analysis_geometry() -> Callable:
103-
"""Create a geometry to be used for analysis."""
107+
"""Create a geometry to be used for analysis.
108+
109+
Returns:
110+
Generator function
111+
"""
104112

105113
def _generate_geom(num_elements: int) -> Geometry:
106114
mat_a = Material("a", 1, 0, 1, 1, color="b")

0 commit comments

Comments
 (0)