Skip to content

Commit

Permalink
Merge pull request #67 from jschneidereit/jschneidereit/66-fix-osx-arm64
Browse files Browse the repository at this point in the history
#66 loosen tolerance for comparing memory consumption
  • Loading branch information
ctrueden authored Jul 23, 2024
2 parents 6868f0c + b414c55 commit bf5910e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
]
python-version: [
'3.8',
'3.9',
'3.10'
'3.10',
'3.12'
]

steps:
Expand Down
3 changes: 2 additions & 1 deletion dev-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ dependencies:
- numpy
- pandas
# Developer tools
- assertpy
- autopep8
- black
- build
- flake8
- flake8-typing-imports
- isort
- pytest
- pytest-cov
Expand All @@ -42,5 +42,6 @@ dependencies:
- pip:
- git+https://github.com/ninia/jep.git@cfca63f8b3398daa6d2685428660dc4b2bfab67d
- flake8-pyproject
- flake8-typing-imports
- validate-pyproject[all]
- -e .
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies = [
[project.optional-dependencies]
# NB: Keep this in sync with dev-environment.yml!
dev = [
"assertpy",
"autopep8",
"black",
"build",
Expand Down
29 changes: 15 additions & 14 deletions tests/it/java_heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
Test scyjava JVM memory-related functions.
"""

from assertpy import assert_that

import scyjava

mb_initial = 50 # initial MB of memory to snarf up
mb_tolerance = 10 # ceiling of expected MB in use

scyjava.config.set_heap_min(mb=mb_initial)
scyjava.config.set_heap_max(gb=1)
Expand All @@ -18,17 +21,15 @@
mb_total = scyjava.memory_total() // 1024 // 1024
mb_used = scyjava.memory_used() // 1024 // 1024

# Used memory should be less than the current memory total,
# which should be less than the maximum heap size.
assert mb_used <= mb_total <= mb_max, f"{mb_used=} {mb_total=} {mb_max=}"

# The maximum heap size should be approximately 1 GB.
assert 900 <= mb_max <= 1024, f"{mb_max=}"

# Most of that memory should still be free; i.e.,
# we should not be using more than a few MB yet.
assert mb_used <= 5, f"{mb_used=}"

# The total MB available to Java at this moment
# should be close to our requested initial amount.
assert abs(mb_total - mb_initial) < 5, f"{mb_total=} {mb_initial=}"
assert_that(
mb_used, "Used memory should be less than the current memory total"
).is_less_than_or_equal_to(mb_total)
assert_that(
mb_total, "current memory total should be less than maximum memory"
).is_less_than_or_equal_to(mb_max)
assert_that(mb_max, "maximum heap size should be approx. 1 GB").is_between(900, 1024)

assert_that(mb_used, "most memory should be available").is_less_than(mb_tolerance)
assert_that(mb_total, "total memory should be close to initial").is_close_to(
mb_initial, tolerance=mb_tolerance
)

0 comments on commit bf5910e

Please sign in to comment.