Profiling a Python program means measuring an execution time of a program. It measures the time spent in each function. Python's cProfile module is used for profiling a Python program.
Profiling and timing programs
The cProfile module
As discussed previously, profiling means measuring the execution time of a program. We are going to use the cProfile Python module for profiling a program.
Now, we will write a cprof_example.py script and write the following code in it:
mul_value = 0
def mul_numbers( num1, num2 ):
mul_value = num1 * num2;
print ("Local Value: ", mul_value)
return mul_value
mul_numbers( 58, 77 )
print ("Global Value: ", mul_value)
Run the program and you will...