Windows - How to Measure Time or Length of Command or Executable

Printer-friendly versionPDF version
Windows - How to Measure Time or Length of Command or Executable

There are serveral reasons you would want to see how long it takes to execute a command, or run a program. Perhaps you are benchmarking a command line application you made, or want to see how long it takes to run the same command on different computers. Whatever your reason, here are 3 ways to measure the time it takes to execute a command or application on Windows. In my example, I'm seeing how long it takes to perform a DNS query (you can replace the underlined portion with the command you want to time):

1. In PowerShell, run the following command:

Measure-Command {nslookup itswapshop.com}

 

2. Here is a one-liner you can run from the command prompt:

cmd /v:on /c "echo !time! & nslookup itswapshop.com & echo !time!"

 

3. Save this at a batch file, and then run it:

echo %time%

nslookup itswapshop.com

echo %time%

 

Here is a screenshot of each method:

Windows - How to Measure Time or Length of Command or Executable

Post new comment