home *** CD-ROM | disk | FTP | other *** search
- /*----------------------------------------------------------------------*/
- /* STOPWTCH.EXE - Times the execution of other program.
- *
- * Version: 2.0.0
- * Date: June 18, 1990
- * Author: Don A. Williams
- *
- ********************* NOTICE ************************
- * Contrary to the current trend in MS-DOS software *
- * this program, for whatever it is worth, is NOT *
- * copyrighted (with the exception of the runtime *
- * library from the C compiler)! The program, in *
- * whole or in part, may be used freely in any *
- * fashion or environment desired. If you find this *
- * program to be useful to you, do NOT send any *
- * contribution to the author; in the words of Rick *
- * Conn, 'Enjoy!' However, if you make any *
- * improvements, I would enjoy receiving a copy of *
- * the modified source. I can be reached, usually *
- * within 24 hours, by messages on any of the *
- * following Phoenix, AZ systems (the Phoenix systems *
- * can all be reached through StarLink node #9532): *
- * *
- * The Tool Shop BBS [PCBOARD] [PC-Pursuit] *
- * (602) 279-2673 1200/2400/9600 bps *
- * Technoids Anonymous [PCBOARD] *
- * (602) 899-4876 300/1200/2400 bps *
- * (602) 899-5233 *
- * (602) 786-9131 *
- * Inn On The Park [PCBOARD] *
- * (602) 957-0631 1200/2400/9600 bps *
- * Pascalaholics Anonymous [WBBS] *
- * (602) 484-9356 1200/2400 bps *
- * *
- * or: *
- * Blue Ridge Express [RBBS] Richmond, VA *
- * (804) 790-1675 2400 bps [StarLink #413] *
- * *
- * The Lunacy BBS [PCBOARD] Van Nuys, CA *
- * (805) 251-7052 2400/9600 [StarLink 6295] *
- * (805) 251-8637 2400/9600 [StarLink 6295] *
- * *
- * or: *
- * GEnie, mail address: DON-WILL *
- * CompuServ: 75410,543 *
- * *
- * Every effort has been made to avoid error and *
- * moderately extensive testing has been performed *
- * on this program, however, the author does not *
- * warrant it to be fit for any purpose or to be *
- * free from error and disclaims any liability for *
- * actual or any other damage arising from the use *
- * of this program. *
- *******************************************************
- */
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <dos.h>
-
- long ElapsedTime (void);
-
- void
- main (int argc, char *argv[]) {
- int i;
- long Seconds, Temp;
- int Tenths;
- int Minutes, Hours;
- char Command[256];
- struct date MyDate;
- struct time OnTime, OffTime;
-
- getdate(&MyDate);
- if (argc > 1) {
- strcpy(Command, argv[1]);
- for (i = 2; i < argc; i++) {
- strcat(Command, " ");
- strcat(Command, argv[i]);
- }
- if (Command[0] == '"') strcpy(Command, &Command[1]);
- for (i = strlen(Command) - 1; (i >= 0) && (Command[i] == ' '); i--);
- if (Command[i] == '"') Command[i] = 0x00;
- }
- else strcpy(Command, "Command");
- gettime(&OnTime);
- ElapsedTime();
- system(Command);
- Temp = ElapsedTime();
- Seconds = (Temp * 100) / 182;
- Tenths = (int) Seconds % 10;
- Seconds = Seconds / 10;
- gettime(&OffTime);
- printf("\nStopWatch - Version 2.0.0: June 18, 1990\n");
- printf(" Turbo C++ 1.0 Compiler Version\n");
- printf("Date: %02d/%02d/%02d\n",
- MyDate.da_mon, MyDate.da_day, MyDate.da_year);
- printf("Command: %s\n", Command);
- printf("Start time: %2d:%02d:%02d\n",
- OnTime.ti_hour, OnTime.ti_min, OnTime.ti_sec);
- printf("Stop time: %2d:%02d:%02d\n",
- OffTime.ti_hour, OffTime.ti_min, OffTime.ti_sec);
- printf("Elapsed time: ");
- if (Seconds > 3600) {
- Hours = (int) Seconds / 3600;
- Seconds = Seconds % 3600;
- printf("%02d:", Hours);
- }
- if (Seconds > 60) {
- Minutes = (int) Seconds / 60;
- Seconds = Seconds % 60;
- printf("%02d:", Minutes);
- }
- printf("%02ld.%01d Seconds\n\n", Seconds, Tenths);
- }