home *** CD-ROM | disk | FTP | other *** search
/ Software Du Jour / SoftwareDuJour.iso / BUSINESS / DBASE / DBAPG.ARC / BNCHMK_1.PRG < prev    next >
Encoding:
Text File  |  1984-12-18  |  2.7 KB  |  112 lines

  1. * Program..: BNCHMK_1.PRG
  2. * Author...: Tom Rettig
  3. * Date.....: May 21, 1984
  4. * Notice...: Copyright 1984 by Ashton-Tate.  All rights reserved.
  5. * Version..: dBASE III, version 1.00, 14 Jun 1984
  6. * Notes....: For measuring the execution time of a single dBASE
  7. *            command.
  8. *
  9. SET TALK OFF
  10. DO WHILE .T.
  11.    n1 = 1
  12.    n2 = 0
  13.    ?
  14.    ? 'Enter a command to execute, or RETURN to exit:'
  15.    ACCEPT '--> ' TO command
  16.    IF '' = command
  17.       SET TALK ON
  18.       RETURN
  19.    ENDIF
  20.    ?
  21.    ?
  22.    ?
  23.    ?
  24.    *
  25.    * Toggle switch algorithm...
  26.    SET BELL OFF
  27.    @ 22, 0 SAY "Talk is set "
  28.    @ 23, 0 SAY "Press SPACE to change, or RETURN to continue."
  29.    SET COLOR TO 15/0
  30.    @ 22,12 SAY "OFF"
  31.    toggle = ' '
  32.    is_on  = .F.
  33.    DO WHILE .NOT. toggle $ '?'
  34.       STORE '?' TO toggle
  35.       SET COLOR TO 0/0
  36.       @ 22,15 GET toggle
  37.       READ
  38.       CLEAR GETS
  39.       SET COLOR TO 15/0
  40.       DO CASE
  41.          CASE toggle = ' ' .AND. is_on
  42.             @ 22,12 SAY "OFF"
  43.             is_on    = .F.
  44.          CASE toggle = ' ' .AND. (.NOT. is_on)
  45.             @ 22,12 SAY "ON "
  46.             is_on    = .T.
  47.       ENDCASE
  48.    ENDDO
  49.    @ 23,0
  50.    IF is_on
  51.       SET TALK ON
  52.    ENDIF
  53.    SET BELL ON
  54.    SET COLOR TO 7/0
  55.    *
  56.    *
  57.    WAIT 'Press any key to START, <Ctrl-Break> to cancel...'
  58.    @ 23,0
  59.    ?
  60.    ? CHR(7) + 'Time started...'
  61.    *
  62.    * Get start time...
  63.    t1 = TIME()
  64.    *
  65.    * Timing loop...   
  66.    DO WHILE n2 < n1
  67.       *----------------Start of timed command-------------------
  68.  
  69.       &command   
  70.  
  71.       *----------------End of timed command---------------------
  72.       n2 = n2+1
  73.    ENDDO
  74.    *
  75.    * Get end time...
  76.    t2 = TIME()
  77.    *
  78.    ? CHR(7) + '***DONE***'
  79.    ?
  80.    ? '         hh:mm:ss'
  81.    ? '  Start:', t1
  82.    ? ' Finish:', t2
  83.    ? '         --------'
  84.    *
  85.    * Elapsed time algorithm:
  86.    IF is_on
  87.       SET TALK OFF
  88.    ENDIF
  89.    *
  90.    * Convert start and end times to numeric seconds; es = elapsed seconds...
  91.    es = ( VAL(t2)*3600 + VAL(SUBSTR(t2,4))*60 + VAL(SUBSTR(t2,7)) ) -;
  92.         ( VAL(t1)*3600 + VAL(SUBSTR(t1,4))*60 + VAL(SUBSTR(t1,7)) )
  93.    *
  94.    * Convert elapsed seconds to 'hh:mm:ss', and add leading zeros...
  95.    et = SUBSTR(STR( INT(es/3600)                       +100,3),2) +':'+;
  96.         SUBSTR(STR( INT(es/  60) - ( INT(es/3600)*60 ) +100,3),2) +':'+;
  97.         SUBSTR(STR(     es       - ( INT(es/  60)*60 ) +100,3),2) 
  98.    *
  99.    * Based on the algorithm:
  100.    * hh  = INT( es / 3600 )
  101.    * mm  = INT( es /   60 ) - (hr*60)
  102.    * ss  =      es          - (mn*60) - (hr*3600)
  103.    * et  = SUBSTR(STR(hh+100,3),2) +':'+ SUBSTR(STR(mm+100,3),2) +':'+ ;
  104.    *       SUBSTR(STR(ss+100,3),2)
  105.    *
  106.    *
  107.    ? 'Elapsed:', et
  108.    ?
  109. ENDDO [WHILE .T.]
  110. *
  111. * EOF: Bnchmk_1.prg
  112.