DEV Community

0xkoji
0xkoji

Posted on

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)