1
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 5 years have passed since last update.

DOSプロンプト上で実行するコマンドの、処理時間を計測したい

Posted at

TL;DR

  • DOSプロンプト上で実行するコマンドの処理時間を計測したい
  • PowerShellのMeasure-Commandを使うのがお手軽

Measure-Command

ここでの手法は、DOSプロンプト上でPowerShellを一時的に起動してMeasure-Commandを使用するやり方です。

Measure-Command

以下のような感じで使います。

>powershell -C Measure-Command {計測したいコマンド}

例。

>powershell -C Measure-Command {echo Hello}
Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 9
Ticks             : 96164
TotalDays         : 1.11300925925926E-07
TotalHours        : 2.67122222222222E-06
TotalMinutes      : 0.000160273333333333
TotalSeconds      : 0.0096164
TotalMilliseconds : 9.6164


>powershell -C Measure-Command {timeout 5}
Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 4
Milliseconds      : 479
Ticks             : 44796443
TotalDays         : 5.18477349537037E-05
TotalHours        : 0.00124434563888889
TotalMinutes      : 0.0746607383333333
TotalSeconds      : 4.4796443
TotalMilliseconds : 4479.6443

Measure-Command()で囲むことで、特定のフィールドのみを取得することもできます。

>powershell -C (Measure-Command {timeout 5}).Seconds
4                      

覚えておきましょう。

1
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
1
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?