Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do you know of a way in which fil can be used with pytest? #491

Open
krishraghuram opened this issue Feb 19, 2023 · 1 comment
Open

Do you know of a way in which fil can be used with pytest? #491

krishraghuram opened this issue Feb 19, 2023 · 1 comment

Comments

@krishraghuram
Copy link

krishraghuram commented Feb 19, 2023

Use-Case: Run fil as part of a test to verify that memory usage doesnt (drastically) increase from one commit to another

I read https://pythonspeed.com/fil/docs/how-it-works.html, and it does mention that,

This is why Fil can’t be used as regular library and needs to be started in a special way: it requires setting up the correct environment before Python starts.

So I thought I'd ask if its possible to setup this special environment from within a pytest test function.

@itamarst
Copy link
Collaborator

https://pythonspeed.com/fil/docs/api.html documents how to profile Python functions, so at minimum you can do:

from filprofiler.api import profile

def test_yourcode():
     profile(_test_yourcode, "/tmp/your-profiling)    

def _test_yourcode():
    # the real test code goes here.

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

No branches or pull requests

2 participants