bloomberg / pytest-memray

pytest plugin for easy integration of memray memory profiler
https://pytest-memray.readthedocs.io/en/latest/
Apache License 2.0
345 stars 24 forks source link

Ability to persist the binary dump post test run #10

Closed gaborbernat closed 2 years ago

gaborbernat commented 2 years ago

Feature Request

I'd like to allow the user to explicitly request persisting the binary files via a --memray-persist-bin flag that can take a folder as an argument. This would change the folder where the temporary files are stored from temporary to the passed in argument. To help identify which binary belongs to which test I'd also propose to add the test name (pyfuncitem.nodeid - might need to normalize the test name for characters not allowed on the path) as a suffix (after the uuid).

This would allow users to do further analysis of the binary files after the run (such as generating a flamegraph). This could be also used for #7. Most often I imagine this using in form of:

pytest -k test_memory_usage --memray --memray-persist-bin ./memray-bins
memray flamegraph ./memray-bins/21321asad213421.test_memory_usage.bin

Describe alternatives you've considered

Users could rewrite their test as a python module invocation and use memray directly. The downside is that making fixtures work as function calls can be complicated.