0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

sleep,timeコマンド、テスト的に時間がかかるコマンドを実行してコマンド実行時間を計測する方法【bash,linux,mac】

Last updated at Posted at 2020-12-13

コマンドライン上でテスト的に時間がかかるコマンドを実行したい場合、sleepコマンドが使えます。

#####sleep,timeコマンド

sleepコマンドは、指定した時間の間、停止状態になります。下のコマンドは10秒間停止します。

$ sleep 10

timeコマンドでコマンドの実行時間を計測できるので、確認してみます。

$ time sleep 10

real	0m10.014s
user	0m0.001s
sys	0m0.006s

コマンド実行時間(real)が10秒になっています。

あと、ただ長時間実行するコマンドを実行したいなら、watch、topコマンドなども使えます。

#####watchコマンド

watchコマンドは定期的に引数に指定したコマンドを繰り返し実行します。

$ watch date

ちなみにmacにはwatchコマンドはデフォルトで入っていないので、インストールする必要がある。

$ brew install watch

#####参考サイト、リンク
【Linux】ターミナル上にて無限ループでコマンドを発行する

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?