I am in the midst of planning for an updated and more accurate antivirus, internet security, total security performance test and one of the test features on measuring the amount of time taken to convert media files and also file compression. There are media converters which shows the total amount of time taken to convert the media files but it only shows second. I wanted a more accurate benchmark time which shows even up to milliseconds but there I couldn’t seem to find any. Finally I figured that I will have to resort to a slightly more sophisticated method in measuring the time taken to complete a command line or batch file execution.
So far I have found 2 command line tools that can accurately measure program execution time and also a good old batch command. Basically we will need to run the batch file or command line after the application that is used to measure the time.
The first tool I found is called ptime for Windows. ptime will run the specified command and measure the execution time (run time) in seconds, accurate to 5 millisecond or better. It is an automatic process timer, or program timer. One usage example is if you want to measure how long it takes to run this command “dir C:/s”, then you should run ptime as “ptime dir c: /s“. Once the dir command has been finished executing, you will see “Execution time: X.XXX s”.
Another similar tool to ptime is called Ultra Precision Command Timer (UPCT) which also works exactly the same as ptime. UPCT can even tell you the measurement in microseconds and seconds. Both ptime and UPCT is very old but it still works on Windows 7.

The more old school way without using any third party tool is to create a batch file and use the %Time% variable to append them to the result file. For example:
ECHO Start Measure %Time% >> timer.txt
YOUR COMMAND GOES HERE
ECHO Stop Measure %Time% >> timer.txt
After running the batch file, you will get a text file called timer.txt showing the date and time before and after running the command line or batch file. Calculate the difference and you have the amount of the time taken to complete the process.

These methods will only work on command line application and not on Windows application with graphical user interface. There in fact another one called Gammadyne’s Timer which belongs to the same category as ptime and upct but for some weird reason it is not capturing the command line parameters. If you want to test it out, you can download it from here.
[ Download ptime | Ultra Precision Command Timer ]

Check out this ultimate batch script that will measure the time taken to run the predefined commands:
thesysadminhimself.com/2011/03/calculating-time-difference-in-batch.html
I need to do an almost impossible task. And I think it can be done with a bat file. Can an expert on bat files please contact me? I just want to know if it is possible. And maybe give me some tips.
@wave, thanks, for prompted by your post, on rereading Raymond’s response to me makes me think that your interpretation of Raymond’s post, as well as my point in my original post, is correct. I.e. you only need to add %Date% if you want the date as well as the time displayed, not that you need to add %Date% to get it to work at all.
I’m pretty sure Raymond misunderstood you. I believe he thought you meant that the command wouldn’t work at all without the %Date% parameter while you were just saying that you need the %Date% parameter if you want the date displayed.
nice tool. thanks ray
Microsoft has also a tool like this in the Windows 2000 Ressource Kit Tools. It’s named timehtis.
I’ve used it yesterday on a Windwos 7 64 Bit computer, so it also runs on newer systems then Windows 2000.
I am so happy that you met
But my problem with unlock software on my feed
Some kind of hack
Accounting Program
I am using XP, if I lock my computer by using windows +L key then how do I know how much time I locked my system, please advice
I love it!
Now we can talk in facts…
Hi Raymond,
Seems like good utilities,
Thanks for the article.
Raymond, strange, for on my W7, Vista and XP laptops I need to add %Date% for the date ti be displayed. Though I do have command extensions enabled which might make a difference as they change the way some of the internal commands work. I’ll have to check when I have %time% :)
BTW, your ‘timer.log’ image is only displaying time.
One other thing for those who need a record, you can add redirection to both the ptime and UPCT command line,
e.g. ptime somecommand.exe > timer.log
or upct somecommand.exe > timer.log
which, unlike the batch file, will send both the output from somecommand.exe as well as the execution time to timer.log. Useful if you want a hard copy of both the command and the time taken. However, as it is only a single > it will overwrite existing entries. Change . to >> to append to existing entries.
Very good!Thanks!
@jcym: I have tried using just %Time% without %Date% and it worked.
Note: you need to add the %date% variable to each line if you want the date as well as the time displayed.
E.G.
ECHO Start Measure %Date% %Time% >> timer.txt
YOUR COMMAND GOES HERE
ECHO Stop Measure %Date% %Time% >> timer.txt