Skip to content

Conversation

@lcheylus
Copy link

  • Add BSD bool variable (= true if running on BSD OS)
  • Use psutil to get memory infos on BSD
  • Use psutil.memory_info().rss on BSD instead of memory_full_info().uss (not supported)

Fix #219


Tests OK on OpenBSD current/amd64 with Python 3.12.11

$ pytest
============================= test session starts =============================
platform openbsd7 -- Python 3.12.11, pytest-8.4.2, pluggy-1.6.0
rootdir: /home/fox/dev/pyperf.git
configfile: pyproject.toml
collected 173 items

pyperf/tests/test_bench.py ...................................          [ 20%]
pyperf/tests/test_cli.py ..                                             [ 21%]
pyperf/tests/test_examples.py ........                                  [ 26%]
pyperf/tests/test_metadata.py .....                                     [ 28%]
pyperf/tests/test_misc.py .........                                     [ 34%]
pyperf/tests/test_perf_cli.py ...................................       [ 54%]
pyperf/tests/test_runner.py .............................               [ 71%]
pyperf/tests/test_system.py .                                           [ 71%]
pyperf/tests/test_timeit.py ...............................             [ 89%]
pyperf/tests/test_utils.py ..................                           [100%]

============================ 173 passed in 47.13s =============================

- Add BSD bool variable (= true if running on BSD OS)
- Use psutil to get memory infos on BSD
- Use psutil.memory_info().rss on BSD instead of memory_full_info().uss
  (not supported)

Signed-off-by: Laurent Cheylus <foxy@free.fr>

def get(self):
usage = self.process.memory_full_info().uss
if BSD:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment to explain this change?

from pyperf._psutil_memory import check_tracking_memory
elif BSD:
from pyperf._psutil_memory import check_tracking_memory
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to do something like:

elif LINUX:
    from pyperf._linux_memory import check_tracking_memory
else:
    from pyperf._psutil_memory import check_tracking_memory

Same remark for MemoryUsage below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Errors with track-memory on OpenBSD

2 participants