Sunday, November 16, 2014

Python Module: time

Module time is my favorite module, usually use to test the speed of my code.

Example:
import time

# start time
start = time.time()

# run the code
for i in xrange(0, 100):
    print i

# end time
end = time.time()

# print the cost time (seconds)
print end - start

No comments:

Post a Comment