DEV Community 👩‍💻👨‍💻


Posted on

GNU timeを知った

High Performance Python 2nd Editionを読む中で、


bashやzshのプロンプトでパスが通っている timeはシェル組み込みのtimeで、簡易版らしい。

# zsh
$ time sleep 1
sleep 1  0.00s user 0.00s system 0% cpu 1.004 total

GNU time


macの場合はbrew install gnu-timeでgtimeとしてインストール可能。

$ gtime --verbose sleep 1
        Command being timed: "sleep 1"
        User time (seconds): 0.00
        System time (seconds): 0.00
        Percent of CPU this job got: 0%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.00
        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): 612
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 297
        Voluntary context switches: 0
        Involuntary context switches: 17
        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

Major (requiring I/O) page faultsは、スワップの発生を意味しており注意すべきメトリクスである。

Top comments (0)

Become a ModeratorHey! We would love your help!

Fill out this survey and help us moderate our community by becoming a tag moderator here at DEV.