DEV Community

0xkoji
0xkoji

Posted on

1

Display Elapsed Time in Python

import time

if __name__ == '__main__':
    start = time.time()
    for i in range(10):
        print('hello dev.to')
    elapsed_time = time.time() - start
    print('elapsed_time {} sec'.format(elapsed_time))
Enter fullscreen mode Exit fullscreen mode
hello dev.to
hello dev.to
hello dev.to
hello dev.to
hello dev.to
hello dev.to
hello dev.to
hello dev.to
hello dev.to
hello dev.to
elapsed_time 0.0004100799560546875 sec
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay