Please be consider that when you are executing a function, the time depends on your algorithm as well as your machine speed. In order to calculate the time without executing the code, you may have to give some initial parameters or else use a machine learning code that will calculate the time of execution by going through the codes but it seems very difficult.
Btw Try this using import timeit.
Just save the time before and after the execution of code and subtract them! But this method is not precise as there might be a background process momentarily running which disrupts the code execution and you will get significant variations in running time of small code snippets.
timeit runs your snippet of code millions of time (default value is 1000000) so that you get the statistically most relevant measurement of code execution time!
# importing the required module
import timeit
# code snippet to be executed only once
mysetup = "from math import sqrt"
# code snippet whose execution time is to be measured
mycode = '''
def example():
mylist = []
for x in range(100):
mylist.append(sqrt(x))
'''
# timeit statement
print timeit.timeit(setup = mysetup,
stmt = mycode,
number = 10000)