loading...

Display Elapsed Time in Python

kojikanao profile image Koji (he/him) ・1 min read
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))
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

Discussion

pic
Editor guide