How do I get time of a Python program's execution?

后端 未结 30 2332
甜味超标
甜味超标 2020-11-22 02:20

I have a command line program in Python that takes a while to finish. I want to know the exact time it takes to finish running.

I\'ve looked at the timeit

30条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 03:01

    You do this simply in Python. There is no need to make it complicated.

    import time
    
    start = time.localtime()
    end = time.localtime()
    """Total execution time in minutes$ """
    print(end.tm_min - start.tm_min)
    """Total execution time in seconds$ """
    print(end.tm_sec - start.tm_sec)
    

提交回复
热议问题