Skip to content

Commit 832c6e4

Browse files
committed
Add performance analysis for python scripts
1 parent 1599386 commit 832c6e4

File tree

7 files changed

+59
-2
lines changed

7 files changed

+59
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.egg-info
33
*.html
44
*.log
5+
*.prof
56
*.py[cod]
67
*.xml
78
.*

.vscode/.gitkeep

Whitespace-only changes.

.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"configurations": [
3+
{
4+
"console": "integratedTerminal",
5+
"env": {
6+
"PYTHONDEBUG": "1",
7+
"PYTHONFAULTHANDLER": "1",
8+
"PYTHONTRACEMALLOC": "1",
9+
"PYTHONUNBUFFERED": "1",
10+
"PYTHONWARNINGS": "all"
11+
},
12+
"justMyCode": false,
13+
"name": "Python Debugger: Debug",
14+
"program": "${file}",
15+
"purpose": [
16+
"debug-test"
17+
],
18+
"request": "launch",
19+
"type": "debugpy"
20+
}
21+
],
22+
"version": "0.2.0"
23+
}

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"python.defaultInterpreterPath": "./.venv/bin/python",
3+
"python.testing.pytestArgs": [
4+
".",
5+
],
6+
"python.testing.pytestEnabled": true
7+
}

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ help:
1919
@echo 'lint - inspect project source code for problems and errors'
2020
@echo 'stubs - create files that include only type hints for the public interface of modules'
2121
@echo 'jupyter - run jupyter server'
22+
@echo 'analysis - run the python script with performance analysis'
2223
@echo 'clean - clean up project environment and all the build artifacts'
2324

2425
.PHONY: lock
@@ -60,6 +61,10 @@ stubs: bootstrap
6061
jupyter: bootstrap
6162
@poetry run jupyter notebook --log-level INFO --ServerApp.notebook_dir $(PWD)
6263

64+
analysis: bootstrap
65+
@poetry run python -m cProfile -o analysis.prof $(or $(PROFILE_SCRIPT), main.py)
66+
@poetry run snakeviz analysis.prof
67+
6368
.PHONY: clean
6469
clean:
6570
git clean -X -d --force

poetry.lock

Lines changed: 22 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pytest = "^8.3"
7575
pytest-cov = "^6.0"
7676
pytest-html = "^4.1"
7777
pytest-mock = "^3.14"
78+
snakeviz = "^2.2"
7879
tox = "^4.24"
7980

8081
[[tool.poetry.source]]

0 commit comments

Comments
 (0)