LoginSignup
1
1

More than 5 years have passed since last update.

timeコマンドで詳細情報を見る

Last updated at Posted at 2018-08-18

概要

一般的なLinuxでは、timeは2種類インストールされている。Linuxコマンドのtimeと、シェル組み込み関数のtimeだ。

Linuxコマンドのtimeは通常/usr/bin/timeにあり、呼び出すときはフルパスで指定する。こちらの/usr/bin/timeは、-vでの詳細表示に対応している。

確認

環境は、Ubuntu 17.10。

テスト用スクリプト

foo.py
#!/bin/bash

# てきとうにループしてCPUを使わせたい
for (( i=0; $i < 1000000; i++ )); do
    :
done

普通はこう。(組み込み関数を使用)

$ time ./foo.sh

real    0m3.751s
user    0m3.745s
sys 0m0.001s

Linuxコマンドを使う。

$ /usr/bin/time ./foo.sh
3.74user 0.00system 0:03.74elapsed 99%CPU (0avgtext+0avgdata 3352maxresident)k
0inputs+0outputs (0major+139minor)pagefaults 0swaps

詳細表示。

$ /usr/bin/time -v ./foo.sh
    Command being timed: "./foo.sh"
    User time (seconds): 3.75
    System time (seconds): 0.00
    Percent of CPU this job got: 99%
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:03.75
    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): 3348
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 0
    Minor (reclaiming a frame) page faults: 138
    Voluntary context switches: 1
    Involuntary context switches: 205
    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

こちらからは以上です。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1