1

Pycharm's standard profiler for python is cProfile or Yappi.
While using cProfile in Pycharm, you don't have to change or edit your code, you just have to use the graphical interface and press the profile button.
However, whenever I do this, Pycharm runs the whole script or file and gives me results. Is there a way to profile only a few lines of code in the script, or maybe a function, In order to save time?

I have tried setting up break points and it didn't do the trick.

Thank you in advance,

Jamal

  • profiling the entire code also profiles whatever function you want to get profiled in that code, just use `snakeviz` to display the output in browser where you can interact with it and get to the function you need – Matiiss Sep 19 '22 at 10:13
  • @Matiiss Surely, but I want to run only a few lines or a function, because running the whole script woul waste a lot of time. Maybe that clears the question a bit more? Thank you! – Jamal Rnjbal Sep 19 '22 at 12:12
  • https://docs.python.org/3/library/profile.html – Matiiss Sep 19 '22 at 12:35

0 Answers0