import time start_time = time.time() main() print("--- %s seconds ---" % (time.time() - start_time)) 

Read more of this post