Skip to content

Commit

Permalink
Add profiling and benckmarking (#513)
Browse files Browse the repository at this point in the history
* Started profiling test suite.

* Tests now need to be able to build package.

* Filtered less for montepy

* Made a big annoying model to stress MontePy for profiling and benchmarking.

* Enabled big model CI work.

* Fixed bad path.

* Fixed benchmark and gave failure condition.

* Increased failure threshold to 4 minutes.

* Learned how to actually get the results from a profile.

* GHA is slow: increased threshold.

* Updated benchmark to not be near line lenght max.
  • Loading branch information
MicahGale authored Aug 28, 2024
1 parent ed6f2d3 commit 884bba7
Show file tree
Hide file tree
Showing 7 changed files with 16,104 additions and 3 deletions.
31 changes: 30 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,36 @@ jobs:
python-version: 3.12
- run: pip install . montepy[format]
- run: black --check montepy/ tests/


profile:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: set up python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- run: pip install . montepy[test]
- run: pytest --profile
name: Profile test suite
- run: python prof/dump_results.py
name: Display pytest profiling data
- run: python prof/profile_big_model.py
name: Profile against big model

benchmark:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: set up python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- run: pip install . montepy[test]
- run: python benchmark/benchmark_big_model.py
name: Benchmark against big model

changelog-test:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dist/*
.coverage
.idea/*
*.*.sw*
*.prof
doc/build/*
.coverage
.idea/
Expand Down
21 changes: 21 additions & 0 deletions benchmark/benchmark_big_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import montepy

import time
import tracemalloc

FAIL_THRESHOLD = 500

tracemalloc.start()
start = time.time()

problem = montepy.read_input("benchmark/big_model.imcnp")

stop = time.time()

print(f"Took {stop - start} seconds")
print(f"Memory usage report: {tracemalloc.get_traced_memory()}")

if (stop - start) > FAIL_THRESHOLD:
raise RuntimeError(
f"Benchmark took too long to complete. It must be faster than: {FAIL_THRESHOLD} s."
)
Loading

0 comments on commit 884bba7

Please sign in to comment.