美文网首页
Python计算程序运行时间

Python计算程序运行时间

作者: Time一柒 | 来源:发表于2020-03-31 18:03 被阅读0次
    import time
    
    # 程序开始时的时间
    time_start=time.time()
    
    # 程序结束时系统时间
    time_end=time.time()
    
    # 两者相减
    print('totally cost',time_end-time_start)
    
    import time
    limit = 10*100*1000
    start = time.perf_counter()
     
    while True:
        limit -= 1
        if limit <= 0:
            break
    delta = time.perf_counter() - start
    print("程序运行的时间是:{}秒".format(delta))
    
    

    相关文章

      网友评论

          本文标题:Python计算程序运行时间

          本文链接:https://www.haomeiwen.com/subject/nxrguhtx.html