Raymond.CC Blog
  • Home
  • Forum
  • Giveaway
  • X-Ray 2.0
  • Contact
  • About
  • I’m Feeling Lucky
Search the site...
You are here: Home » Computer » Measure Time Taken to Complete a Batch File or Command Line Execution

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

Updated by Raymond - 2 years ago - Computer
14
  • Like
  • +1
  • Tweet
  • Printer Friendly and PDF

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.

ultra precision command timer ptime

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.

Measure Batch File Timer

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 ]


Didn't find what you want? The links below could help:

Memory Usage Test to See Which is the Lightest Antivirus SoftwareMemory Usage Test to See Which is the Lightest Antivirus SoftwareComprehensive List of 26 Bootable Antivirus Rescue CDs for Offline ScanningComprehensive List of 26 Bootable Antivirus Rescue CDs for Offline ScanningComprehensive List of Uninstallers or Removal Tools for Antivirus SoftwareComprehensive List of Uninstallers or Removal Tools for Antivirus SoftwareTest the Effectiveness of Your Antivirus, Firewall and HIPS SoftwareTest the Effectiveness of Your Antivirus, Firewall and HIPS Software

14 comments on “Measure Time Taken to Complete a Batch File or Command Line Execution”

  1. Levente Rog says:
    2 years ago

    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

    Reply
  2. melvill louw says:
    2 years ago

    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.

    Reply
  3. jcym says:
    2 years ago

    @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.

    Reply
  4. wave says:
    2 years ago

    jcym said<: Raymond, strange, for on my W7, Vista and XP laptops I need to add %Date% for the date ti be displayed.

    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.

    Reply
  5. norman says:
    2 years ago

    nice tool. thanks ray

    Reply
  6. Mario says:
    2 years ago

    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.

    Reply
  7. Eiman says:
    2 years ago

    I am so happy that you met
    But my problem with unlock software on my feed
    Some kind of hack
    Accounting Program

    Reply
  8. chandu says:
    2 years ago

    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

    Reply
  9. Phil says:
    2 years ago

    I love it!
    Now we can talk in facts…

    Reply
  10. Sandeep Jopat says:
    2 years ago

    Hi Raymond,
    Seems like good utilities,
    Thanks for the article.

    Reply
  11. jcym says:
    2 years ago

    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.

    Reply
  12. witcher says:
    2 years ago

    Very good!Thanks!

    Reply
  13. Raymond says:
    2 years ago

    @jcym: I have tried using just %Time% without %Date% and it worked.

    Reply
  14. jcym says:
    2 years ago

    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

    Reply

Leave a Reply Cancel reply

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

Recently Updated

  • sniff hidden url

    5 Simple Tools to Display Hidden Remote URLs in Background or Web Installers

  • uac icon

    4 Ways to Disable User Account Control (UAC) for Specific Software in Windows

  • scan shared folder icon

    5 Tools to Scan Connected Computers on the Local Network and Find Shared Folders

New Articles

  • task manager replacement icon

    Memory Usage Test to See Which is the Lightest Antivirus Software

  • kaspersky antivirus 2013 icon

    Activate Free Kaspersky Anti-Virus 2013 ROG with 1 Year License

  • remote access software

    Top 8 Remote Access Software for Providing Online Support

Popular Posts

  • Top 10 FREE Data Recovery Software

    Top 10 FREE Data Recovery Software

  • How to Hack Into a Windows XP Computer Without Changing Password

    How to Hack Into a Windows XP Computer Without Changing Password

  • 10 Free Software to Mount CD or DVD ISO Image File as Virtual Drives

    10 Free Software to Mount CD or DVD ISO Image File as Virtual Drives

Recommend on Google
Follow @raymond_cc
Subscribe Youtube »
(c) 2013 Raymond.CC Blog
  • Contact
  • Disclaimer
  • Disclosure
  • Privacy Policy
  • Terms of Use
  • Sitemap