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

后端 未结 30 2109
甜味超标
甜味超标 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:03

    Even better for Linux: time

    $ time -v python rhtest2.py
    
        Command being timed: "python rhtest2.py"
        User time (seconds): 4.13
        System time (seconds): 0.07
        Percent of CPU this job got: 91%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:04.58
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 0
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 15
        Minor (reclaiming a frame) page faults: 5095
        Voluntary context switches: 27
        Involuntary context switches: 279
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0
    

提交回复
热议问题