home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / SYSTEM / STOP20.ZIP / STOPWTCH.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-18  |  5.0 KB  |  116 lines

  1. /*----------------------------------------------------------------------*/
  2. /*    STOPWTCH.EXE - Times the execution of other program.
  3.  *
  4.  *     Version:    2.0.0
  5.  *     Date:        June 18, 1990
  6.  *     Author:        Don A. Williams
  7.  *
  8.             *********************  NOTICE  ************************
  9.             *  Contrary to the current trend in MS-DOS  software  *
  10.             *  this  program,  for whatever it is worth,  is NOT  *
  11.             *  copyrighted (with the exception  of  the  runtime  *
  12.             *  library  from  the C compiler)!  The program,  in  *
  13.             *  whole or in part,  may  be  used  freely  in  any  *
  14.             *  fashion or environment desired.  If you find this  *
  15.             *  program  to  be  useful  to you,  do NOT send any  *
  16.             *  contribution to the author;  in the words of Rick  *
  17.             *  Conn,   'Enjoy!'   However,   if   you  make  any  *
  18.             *  improvements,  I would enjoy receiving a copy  of  *
  19.             *  the  modified source.  I can be reached,  usually  *
  20.             *  within 24  hours,  by  messages  on  any  of  the  *
  21.             *  following Phoenix, AZ systems (the Phoenix systems *
  22.             *  can all be reached through StarLink node #9532):   *
  23.             *                                                     *
  24.             *     The Tool Shop BBS       [PCBOARD] [PC-Pursuit]  *
  25.             *         (602) 279-2673   1200/2400/9600 bps         *
  26.             *     Technoids Anonymous     [PCBOARD]               *
  27.             *         (602) 899-4876   300/1200/2400 bps          *
  28.             *         (602) 899-5233                              *
  29.             *         (602) 786-9131                              *
  30.             *     Inn On The Park         [PCBOARD]               *
  31.             *         (602) 957-0631   1200/2400/9600 bps         *
  32.             *     Pascalaholics Anonymous [WBBS]                  *
  33.             *         (602) 484-9356   1200/2400 bps              *
  34.             *                                                     *
  35.             *  or:                                                *
  36.             *     Blue Ridge Express     [RBBS] Richmond, VA      *
  37.             *         (804) 790-1675   2400 bps [StarLink #413]   *
  38.             *                                                     *
  39.             *     The Lunacy BBS         [PCBOARD] Van Nuys, CA   *
  40.             *         (805) 251-7052   2400/9600 [StarLink 6295]  *
  41.             *         (805) 251-8637   2400/9600 [StarLink 6295]  *
  42.             *                                                     *
  43.             *  or:                                                *
  44.             *     GEnie, mail address: DON-WILL                   *
  45.             *     CompuServ:           75410,543                  *
  46.             *                                                     *
  47.             *  Every  effort  has  been  made to avoid error and  *
  48.             *  moderately extensive testing has  been  performed  *
  49.             *  on  this  program,  however,  the author does not  *
  50.             *  warrant it to be fit for any  purpose  or  to  be  *
  51.             *  free  from  error and disclaims any liability for  *
  52.             *  actual or any other damage arising from  the  use  *
  53.             *  of this program.                                   *
  54.             *******************************************************
  55. */
  56.  
  57. #include <stdlib.h>
  58. #include <stdio.h>
  59. #include <string.h>
  60. #include <dos.h>
  61.  
  62. long ElapsedTime (void);
  63.  
  64.  void
  65. main (int argc, char *argv[]) {
  66.     int             i;
  67.     long            Seconds, Temp;
  68.     int                Tenths;
  69.     int             Minutes, Hours;
  70.     char            Command[256];
  71.     struct date        MyDate;
  72.     struct time        OnTime, OffTime;
  73.  
  74.     getdate(&MyDate);
  75.     if (argc > 1) {
  76.         strcpy(Command, argv[1]);
  77.         for (i = 2; i < argc; i++) {
  78.             strcat(Command, " ");
  79.             strcat(Command, argv[i]);
  80.             }
  81.         if (Command[0] == '"') strcpy(Command, &Command[1]);
  82.         for (i = strlen(Command) - 1; (i >= 0) && (Command[i] == ' '); i--);
  83.         if (Command[i] == '"') Command[i] = 0x00;
  84.         }
  85.     else strcpy(Command, "Command");
  86.     gettime(&OnTime);
  87.     ElapsedTime();
  88.     system(Command);
  89.     Temp = ElapsedTime();
  90.     Seconds = (Temp * 100) / 182;
  91.     Tenths  = (int) Seconds % 10;
  92.     Seconds = Seconds / 10;
  93.     gettime(&OffTime);
  94.     printf("\nStopWatch - Version 2.0.0: June 18, 1990\n");
  95.     printf("    Turbo C++ 1.0  Compiler Version\n");
  96.     printf("Date:         %02d/%02d/%02d\n",
  97.             MyDate.da_mon, MyDate.da_day, MyDate.da_year);
  98.     printf("Command:      %s\n", Command);
  99.     printf("Start time:   %2d:%02d:%02d\n",
  100.             OnTime.ti_hour, OnTime.ti_min, OnTime.ti_sec);
  101.     printf("Stop time:    %2d:%02d:%02d\n",
  102.             OffTime.ti_hour, OffTime.ti_min, OffTime.ti_sec);
  103.     printf("Elapsed time: ");
  104.     if (Seconds > 3600) {
  105.         Hours = (int) Seconds / 3600;
  106.         Seconds = Seconds % 3600;
  107.         printf("%02d:", Hours);
  108.         }
  109.     if (Seconds > 60) {
  110.         Minutes = (int) Seconds / 60;
  111.         Seconds = Seconds % 60;
  112.         printf("%02d:", Minutes);
  113.         }
  114.     printf("%02ld.%01d Seconds\n\n", Seconds, Tenths);
  115.     }
  116.