Skip to content

Commit 8c9050b

Browse files
perf(tidy3d): FXC-3721 Speed up test suite
1 parent 603c8a8 commit 8c9050b

File tree

16 files changed

+437
-299
lines changed

16 files changed

+437
-299
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,6 @@ htmlcov/
135135
.idea
136136
.vscode
137137

138-
# cProfile output
138+
# profile outputs
139139
*.prof
140+
pytest_profile_stats.txt

docs/development/usage.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ There are a range of handy development functions that you might want to use to s
6767
* - Running ``pytest`` commands inside the ``poetry`` environment.
6868
- Make sure you have already installed ``tidy3d`` in ``poetry`` and you are in the root directory.
6969
- ``poetry run pytest``
70+
* - Analyze slow ``pytest`` runs with durations / cProfile / debug subset helpers.
71+
- Use ``--debug`` to run only the first N collected tests or ``--profile`` to capture call stacks.
72+
- ``python scripts/profile_pytest.py [options]``
7073
* - Run ``coverage`` testing from the ``poetry`` environment.
7174
-
7275
- ``poetry run coverage run -m pytest``
@@ -84,4 +87,3 @@ There are a range of handy development functions that you might want to use to s
8487
- ``poetry run tidy3d develop replace-in-files``
8588

8689

87-

poetry.lock

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

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pytest-timeout = { version = "*", optional = true }
6565
pytest-xdist = "^3.6.1"
6666
pytest-cov = "^6.0.0"
6767
pytest-env = "^1.1.5"
68+
pytest-order = { version = "^1.2.1", optional = true }
6869
tox = { version = "*", optional = true }
6970
diff-cover = { version = "*", optional = true }
7071
zizmor = { version = "*", optional = true }
@@ -154,6 +155,7 @@ dev = [
154155
'pytest-xdist',
155156
'pytest-env',
156157
'pytest-cov',
158+
'pytest-order',
157159
'rtree',
158160
'ruff',
159161
'sax',
@@ -312,9 +314,10 @@ banned-module-level-imports = ["scipy", "matplotlib"]
312314

313315
[tool.pytest.ini_options]
314316
# TODO: remove --assert=plain when https://github.com/scipy/scipy/issues/22236 is resolved
315-
addopts = "--cov=tidy3d --doctest-modules -n auto --dist worksteal --assert=plain -m 'not numerical'"
317+
addopts = "--cov=tidy3d --doctest-modules -n auto --dist worksteal --assert=plain -m 'not numerical and not perf'"
316318
markers = [
317319
"numerical: marks numerical tests for adjoint gradients that require running simulations (deselect with '-m \"not numerical\"')",
320+
"perf: marks tests which test the runtime of operations (deselect with '-m \"not perf\"')",
318321
]
319322
env = ["MPLBACKEND=Agg", "OMP_NUM_THREADS=1", "TIDY3D_MICROWAVE__SUPPRESS_RF_LICENSE_WARNING=true"]
320323
doctest_optionflags = "NORMALIZE_WHITESPACE ELLIPSIS"

0 commit comments

Comments
 (0)