timeはUNIXやLinuxなどのOS上で、指定されたコマンドの実行時間を得るために用いられるプログラムである。

使用例

最も簡単な利用方法は、実行時間を計測したいコマンドの前に、timeを付けるだけである。

time ls

指定されたコマンド(ここではlsコマンド)の実行完了後に、timeは実行に要した時間、具体的にはUser CPU時間、System CPU時間、Real CPU時間を返す。

$ time host wikipedia.org
wikipedia.org has address 103.102.166.224
wikipedia.org mail is handled by 50 mx2001.wikimedia.org.
wikipedia.org mail is handled by 10 mx1001.wikimedia.org.
host wikipedia.org  0.04s user 0.02s system 7% cpu 0.780 total
$

CPU時間

Real CPU時間とは、プログラムがその内部処理に要した時間と、プログラムがカーネルに対してシステムコールを行うのに要した時間の合計である。たとえばプログラム中でループ処理をしているときに費やしている時間はUser CPU時間であり、execやfork等のシステムコールを行うのに要した時間はSystem CPU時間である。Real CPU時間は双方を合計したものである。

関連項目

  • UNIX時間
  • cron : コマンドの定時実行スケジューラ
  • at : コマンドの定時実行スケジューラ
  • sleep

外部リンク

  • JM Projectのtimeマニュアルページ
  • time(1) man page(SunOS リファレンスマニュアル)
  • time(1) man page(HP-UX リファレンス)

Unix Time Converter Free Online Convert Unix to Time

What is Unix time? Dreams wire

UNIX Time Clock Hackster.io

Time (UNIX) Time (Unix) JapaneseClass.jp

Unix time Simple English Wikipedia, the free encyclopedia