0 votes
1 view
in Python by (4.1k points)
recategorized by

Is there any way to profile how long a python program will take to run?

I participated in some coding competition and I noticed that they have maximum time to run a code or people try to boast their solution speed, And in Python specifically the approaches  seems a little bit awkward in other words adding timing code to _main_.

1 Answer

0 votes
by (107k points)

To profile a Python script you can call it within your code, or from the interpreter, like as follows:-

import cProfile 

cProfile.run('foo()')

Related questions

+3 votes
2 answers
+1 vote
1 answer
+2 votes
2 answers
+3 votes
2 answers
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...