Timing a command on Windows?

On *nix system, we can use the command “time” to measure a command execution time. How do I do this on Windows? Fortunately there is a Powershell command “Measure-Command” for this.

PS C:> Measure-Command {certutil -hashfile .\tmuninst.ini | Out-Host}
SHA1 hash of file .\tmuninst.ini:
7c 85 c2 94 73 8d 25 3e 12 8b eb 7a 1d a8 e7 b7 78 ec ee 8f
CertUtil: -hashfile command completed successfully.

Days : 0
Hours : 0
Minutes : 0
Seconds : 0
Milliseconds : 37
Ticks : 375544
TotalDays : 4.34657407407407E-07
TotalHours : 1.04317777777778E-05
TotalMinutes : 0.000625906666666667
TotalSeconds : 0.0375544
TotalMilliseconds : 37.5544

The Out-Host option will give the output from the actual command as well. Here in the example the output from the command certutil shows the SHA1 hash code of the file. Without it, the output from certutil is omitted.

To get a different hash code, use

Measure-Command {certutil -hashfile .\tmuninst.ini [HashAlgorithm] | Out-Host}

For example — SHA256:

Measure-Command {certutil -hashfile .\tmuninst.ini sha256 | Out-Host}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s