7 Ways to Measure Time Taken to Complete a Batch File or Command Line Execution

The ability to write batch commands will greatly help a computer user to automate simple tasks without the need to learn a programming language to write a dedicated program for it or to even install the bulky development software such as Microsoft Visual Studio. All you need to do is launch Notepad and start writing the commands, then saving it with a .bat extension where Windows operating system will automatically recognize that it is a batch file.

Running the .bat file will instantly trigger to run the multiple commands in order but sometimes certain commands can fail when they are run too closely to each other. A simple solution is to measure the approximate amount of time taken to completely execute a command, specifying a delay in between and continuing with the next line.

Apart from that, getting an execution time for a command line can also be used for benchmarking purposes. Some examples are measuring the time taken to copy files between computers, or hard drives. Here we have 7 different methods that you can use to track the execution time of a command. 1. ptime

ptime is a small and free tool that was released back in 2002 but still works perfectly in Windows 8.1. Using ptime to measure the amount of time to finish executing a command is as easy as adding the command after the filename. The example command below will measure the amount of time taken to list all files and folders from C:\ drive.

ptime.exe dir C:\ /s

ptime claims that the measured execution time is accurate to 5 millisecond or better.


Download ptime

2. TimeThis

TimeThis is an official Microsoft tool from the Windows 2000 Resource Kit. TimeThis is a very old program released back in year 2000 but still works fine in Windows 8.1. The TimeThis.exe executable file is installed in C:\Program Files\Resource Kit\ and the installer doesn’t set a path that allows the TimeThis.exe tool to be ran anywhere so make sure you change to the Resource Kit directory to run TimeThis.


The usage of TimeThis is exactly the same as ptime. Simply append the command after timethis to measure the time to run the command.

Download TimeThis

3. Gammadyne Timer

The usage of Gammadyne Timer is slightly different than the first two tool mentioned above. It functions as a timer whereby calling the program the first time will start the timer and running it again with a /s switch will stop timer and report the measured elapsed time. Below is an example of a batch file using Gammadyne Timer to count the amount of time taken to complete executing the io.exe test file.

timer.exe /s

Gammadyne Timer only shows up to decisecond while ptime and timethis shows up to milliseconds.

gammadyne timer

Download Gammadyne Timer

4. TimeMem

TimeMem is a much newer application that is ported from the Unix time utility. Instead of just showing the total time of executing a command, it also provides other information pertaining to memory usage and IO statistics such as exit code, kernel time, user time, page fault, working set, paged pool, non-paged pool and page file size.


TimeMem requires msvcr100.dll, a Microsoft C runtime library file in order to run or else it would show an error popup saying “The program can’t start because MSVCR100.dll is missing from your computer. Try reinstalling the program to fix this problem”. If you do not have the file, you can download from here and place it at the same location as TimeMem.

Download TimeMem

5. PowerShell

PowerShell is a more advanced command line shell that you can find built-in to Windows starting from 7 so there is no need to use any third party tool to measure the time to execute a command. A cmdlet Measure-Command can be used to measure the time it takes to run a command.

Measure-Command { .\io.exe }

Do take note that it is important to wrap the command that you want to measure with left and right curly brackets or else you’ll get an invalid argument error.

powershell measure command

6. Ultra Precision Command Timer

Ultra Precision Command Timer is the oldest tool in this category that you can find dated back to 1993 and was created to measure execution time of DOS commands. Running it on Windows 8.1 will prompt you to install a legacy component NTVDM because this tool is a 16-bit application but it still works, but not on 64-bit operating system.

ultra precision command timer

You’d be surprised that this old tool is the only one that can measure up to microseconds!

Download Ultra Precision Command Timer

7. %TIME%

Some people would have forgotten that you can actually print the current time and date in command line or DOS with %TIME% and %DATE%. This method would work quite similarly to Gammadyne Timer by printing the current time before and after running the command and save the time to an external timer.txt file.

ECHO Start Measure %Time% >> timer.txt
ECHO Stop Measure %Time% >> timer.txt

The only problem is you have to manually calculate the time differences between the two from the timer.txt file to get the total time to execute the command.

dos time variable

4 Comments - Write a Comment

  1. norman 6 years ago
  2. Phil 6 years ago
  3. Sandeep Jopat 6 years ago
  4. witcher 6 years ago

Leave a Reply

Your email address will not be published. Required fields are marked *

Note: Your comment is subject to approval. Read our Terms of Use. If you are seeking additional information on this article, please ask in our forum or contact us directly.