home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPHRTV2.ZIP / DEMOV2.PAS next >
Encoding:
Pascal/Delphi Source File  |  1989-02-04  |  3.2 KB  |  81 lines

  1. {----------------------------------------------------------------------------
  2.  |  Program DEMOV2.PAS                                                      |
  3.  |                                                                          |
  4.  |  This program demonstrates some of the capabilities of TPHRT V2.00       |
  5.  |                                                                          |
  6.  |  (c) 1988 Ryle Design, P.O. Box 22, Mt. Pleasant, Michigan 48804         |
  7.  ----------------------------------------------------------------------------}
  8.  
  9. uses
  10.     CRT, TPHRT;
  11.  
  12. var
  13.     hits, elapsed : longint;
  14.     indx          : integer;
  15.  
  16.  
  17. procedure sin_funct;
  18. {----------------------------------------------------------------------------
  19.  |  A simple procedure to time.   TPHRT will tell us how many this function |
  20.  |  was called and how much time we spent here.                             |
  21.  |                                                                          |
  22.  |  Globals referenced: none                                                |
  23.  |                                                                          |
  24.  |  Arguments: void                                                         |
  25.  |                                                                          |
  26.  |  Returns  : void                                                         |
  27.  ----------------------------------------------------------------------------}
  28. var
  29.     alpha : real;
  30.  
  31. begin
  32.     
  33.     t_entry(3);                                             { start a timer }
  34.  
  35.     alpha := sin(2.2734593);                                { do something  }
  36.  
  37.     t_exit(3);                                              { stop timer    }
  38.  
  39. end; { sin_funct }
  40.  
  41.  
  42. {---------------------------------------------------------------------------}
  43.  
  44.  
  45. begin
  46.  
  47.     t_start;                                                { turns on TPHRT }
  48.     t_entry(1);                                             { use  timer 1 to time whole run }
  49.  
  50.     writeln('TPHRT V2.00 demonstration');
  51.     writeln('Press any key ... ');
  52.  
  53.     t_entry(2);                                             { start timer # 2 }
  54.  
  55.     while (keypressed = FALSE) do;                          { wait for key }
  56.  
  57.     t_exit(2);                                              { stop timer # 2 }
  58.  
  59.     t_ask_timer(2,hits,elapsed);                            { query timer # 2 }
  60.  
  61.     writeln('Response time was ',elapsed,' microseconds, or ',(elapsed/1000000.0):10:6,' seconds.');
  62.  
  63.     write('Calling sin function with embedded timer 100 times ... ');
  64.     for indx := 1 to 100 do sin_funct;
  65.     writeln('complete.');
  66.  
  67.     t_exit(1);                                              { shut down main timer }
  68.     t_stop;                                                 { disable TPHRT }
  69.  
  70.     t_rname('TPHRT Demonstration');                         { title timer report }
  71.     t_name(1,'Total run time');                             { give each timer a name }
  72.     t_name(2,'Keyboard response');
  73.     t_name(3,'sin function');
  74.     
  75.     t_report(0);                                            { do report - 0 goes to CRT }
  76.  
  77.     writeln('TPHRT demo complete.');
  78.  
  79. end. { demov2 }
  80.     
  81.