I just want to measure the time it takes a program to go from start to finish.
In UNIX - I can use the time
command. Is there any way to do this in a MS DOS or FreeDOS?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityThere is not. But you can emulate something like with commands:
echo.|time
your_command
echo.|time
and calculate the difference between two times
One very sample C program like this can help you:
#include <stdio.h>
#include <time.h>
int main(int argc, char** argv)
{
time_t a, b;
a=time(NULL);
system(argv[1]);
b=time(NULL);
printf("%d\n", b-a);
}
4DOS is a command interpreter similar to Command, but contains extensions such as the ability to scroll back through previous commands, pop-up help, and other useful features. 4DOS was written by Rex Conn and Tom Rawson, both of JP Software.
It's the most famous alternative shell that's vastly superior to COMMAND.COM and has a TIMER
command for your purpose
The
TIMER
command lets you time events. The following line also shows 4DOS's ability to accept multiple commands on one line, separated by a caret [^
]. It starts the timer, runs the TOUR2.BTM file to create the three demonstration files, deletes the three files, and then stops the timer and displays the time the whole operation took. Enter this command to time the entire sequence on your computer:c:\4dos> timer ^ tour2 ^ del filel file2 file3 ^ timer Timer 1 on: 11:10:01 Please wait ... File creation completed Deleting c:\4dos\file1 Deleting c:\4dos\file2 Deleting c:\4dos\file3 3 file(s) deleted Timer 1 off: 11:10:06 elapsed: 0:00:05.11
jpsoftware :: 4DOS Reference Manual
[page 37 - Chapter 3 / A guided tour of 4DOS # Other commands] — Text transcription for easy searching, but slightly incorrect due to OCR
(Alternative link)
In fact 4DOS is the predecessor of Take Command / TCC shell in Windows which also has the TIMER
command
I found out that there is a program called RUNTIME.EXE
on the FreeDOS 1.3 Bonus CD in the package RUNTIME.ZIP
. This allows to measure the time it takes a program to run. It's quite similar to unix's time command.