Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python measure time

import time

start = time.time()
print("hello")
end = time.time()
print(end - start)
Comment

python: measure time code

import time

# Calculate the power of two for a defined range of number
def power_two(my_range):
    return [x**2 for x in range(my_range)]
 
# Measure time
def measure_time(func):
    start = time.time()
    func()               # any specific function to measure
    end = time.time()
    print(end - start)  
    
measure_time(lambda: power_two(10000000)) # lambda permits to pass the argument of our function
Comment

calculate time python

>>> import datetime
>>> a = datetime.datetime.now()
>>> # ...wait a while...
>>> b = datetime.datetime.now()
>>> print(b-a)
0:03:43.984000
Comment

PREVIOUS NEXT
Code Example
Python :: upgrade python version mc 
Python :: python reload lib jupyter notebook %reload 
Python :: column dataframe to int 
Python :: matplotlib equal axis 
Python :: python print traceback from exception 
Python :: python move file 
Python :: install docx python 
Python :: clear_output jupyter 
Python :: pip pickle 
Python :: check filed exist in object python 
Python :: how to talk to girls 
Python :: sns set figure size 
Python :: how to get file name without extension in python 
Python :: boucle for python 
Python :: use incognito in selenium webdriver 
Python :: find common elements in two lists python 
Python :: set axis labels python 
Python :: sns title 
Python :: how to check weather my model is on gpu in pytorch 
Python :: esp32 micropython timer 
Python :: python reimport py file 
Python :: export dataframe csv python 
Python :: python regex flags 
Python :: python calculate time taken 
Python :: pig latin translator python 
Python :: Tk.destroy arguments 
Python :: search code ascii python 
Python :: pyspark import f 
Python :: change size of selenium window 
Python :: pandas - from umeric to string 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =