python call time decorator detection function of time

Running time with a decorator, monitoring program

Import Time 

DEF count_time (FUNC):
     DEF int_time (* args, ** kwargs): 
        start_time = time.time ()   # program start time 
        FUNC () 
        over_time = time.time ()    # program end time 
        TOTAL_TIME = over_time - start_time
         Print ( ' program seconds total% s ' % TOTAL_TIME) 

    return int_time 

@count_time 
DEF main ():
     Print ( ' >>>> function of time counted ' ) 
    X = 0
     for i in range(1000000):
        x=x//13
    print(x)

if __name__ == '__main__':
    main()

 

Guess you like

Origin www.cnblogs.com/duoba/p/11784576.html