-
-
Notifications
You must be signed in to change notification settings - Fork 318
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
add profiling functionality to feature-engine #592
Comments
Hi @solegalli
|
Hey @Okroshiashvili
I am new to this, so I asked for help to @ChristopherGS I copy here the notes that I got from him:
Now add this decorator to the top most level function you call when doing something you want to profile (you might have to write a script, or you could use an e2e test) For easy viz, checkout: https://jiffyclub.github.io/snakeviz/ |
Thanks for your input @solegalli I pick this one and will update you whenever I will have some result |
Hi @solegalli So, I found great library for profiling the timings of anything in Python. It is Pyinstrument. Briefly, it is statistical profiler and imposes less burden to the code. Meaning that, it's much faster then conventional profilers. Moreover, its output is really easy to digest. You can quickly look at the documentation and check its benefits. I created small function which we use as a decorator to profile any method inside a class. Note that decorating and profiling class will not give us correct result. If we profile class with this decorator then we will get the timings of class constructor, that is
Put this function somewhere and import it anywhere you want. Then decorate class method with this function in the following way:
This will produce Note that, is HTML file is empty that's fantastic. That means that the code/method/class took less than 1 millisecond to execute. What's your thoughts? |
The package has half a million downloads per month. Sounds good 🍾 Thank you @Okroshiashvili Happy for you to move forward with this 👍🏽 |
Thanks @solegalli What's the resolution of this issue? Can we consider it as done and close? |
Why close it? we need to add the functionality first. |
Where we need to add this functionality? |
What about to create utility module and put this function there? Whenever we need to profile class method we import and decorate that method. Is that okay? |
Yes, that'll work. Let's create a "profiling" module. So everybody knows what the module is about and what to find there. |
One more question, please. Where we want to have that module? In root directory or somewhere else? |
In the root directory sounds OK to me. |
Regarding the memory profiling, I've researched possible libraries and most of them seems either too outdated or not so outdated. Then I found this profiler from bloomberg. What I tested so far it seems quite good and actively supported. What do you think? Should we bring it into the feature_engine project? Since memory profiling will be for only devs then it should not be an issue 🤔 |
This might be a totally ignorant question, but why do we need alternative profilers? does cprofile not provide what we need? |
cprofile is not able to do memory profiling. It only can do speed profiling. Python has built in tracemalloc for memory profiling. However, its API is a bit inconvenient. What I suggested to use for memory profiling, namely memray is much better in terms of API and easy to use and is actively maintained. As I remember you asked me to have both speed and memory profiler. It's just matter of decision either we need to have these profilers or not. I just tried to have the best possible profilers. I will update docs to let and other devs know how to use these profilers. |
Thank you for the explanation! |
Using cProfile, we need to be able to test the performance of the entire library.
The text was updated successfully, but these errors were encountered: