0

How do I check how long it takes for my code to execute. Is there an inbuilt way in python. Or is there some hidden tool in my IDE PyCharm that let's me do so.

ChrisIkeokwu
  • 121
  • 1
  • 1
  • 9

2 Answers2

2

You could try with

cProfile

in this way:

import cProfile
def myFunc():
   ...

cProfile.run('myFunc()')

Hope this solves your question!

Shawn. L
  • 403
  • 1
  • 3
  • 13
0

So profiler is already builtin tool in Pycharm, it uses cProfiler by default if you don't have yappi installed. Here is the link to it PyCharm profiler.

And if you want profile your code without any attachment to PyCharm, check that SO question How can you profile a Python script?

Community
  • 1
  • 1
vishes_shell
  • 22,409
  • 6
  • 71
  • 81