home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / piwg / a000054.ada < prev    next >
Encoding:
Text File  |  1988-05-03  |  1.8 KB  |  53 lines

  1. -- A000054
  2. --
  3. -- This is an executable procedure that can be called outside
  4. -- whatever is being measured.
  5. -- This version works in conjunction with A000052,A000054,A000055
  6. -- to measure CPU time and WALL time without modifying the tests
  7. -- There will be a file named A000052D created and used by these
  8. -- procedures.
  9. --
  10. -- USAGE :
  11. --             A000052
  12. --               optional control
  13. --             A000053
  14. --             A000054
  15. --               test being measured
  16. --             A000055
  17. --
  18. -- RESULT :
  19. --             ( (55) - (54) ) - ( (53) - (52) ) is the measurement
  20. --
  21. --             The second expression takes out the time to make the
  22. --             measurement. As a check, (3) - (2) should be close to (2) - (1)
  23. --
  24. --             The printout gives the CPU and WALL time in seconds for
  25. --             the run being measured.
  26. --
  27.  
  28. with CPU_TIME_CLOCK ;  -- various choices on tape
  29. with CALENDAR ; -- used for WALL clock times
  30. with TEXT_IO ;  -- for printing times
  31. with DURATION_IO ; -- for printing times
  32.  
  33. procedure A000054 is
  34.   MY_FILE : TEXT_IO.FILE_TYPE ;
  35.   HOLD_1 : STRING ( 1 .. 80 ) ;
  36.   HOLD_2 : STRING ( 1 .. 80 ) ;
  37.   LENGTH : NATURAL ;
  38. begin
  39.   TEXT_IO.OPEN ( MY_FILE , TEXT_IO.IN_FILE , "A000052D" ) ;
  40.   TEXT_IO.GET_LINE ( MY_FILE , HOLD_1 , LENGTH ) ;
  41.   TEXT_IO.GET_LINE ( MY_FILE , HOLD_2 , LENGTH ) ;
  42.   TEXT_IO.CLOSE ( MY_FILE ) ;
  43.   TEXT_IO.OPEN ( MY_FILE , TEXT_IO.OUT_FILE , "A000052D" ) ;
  44.   TEXT_IO.PUT_LINE ( MY_FILE , HOLD_1 ( 1 .. LENGTH ) ) ;
  45.   TEXT_IO.PUT_LINE ( MY_FILE , HOLD_2 ( 1 .. LENGTH ) ) ;
  46.   TEXT_IO.PUT ( MY_FILE , " '54 CPU time =" ) ;
  47.   DURATION_IO.PUT ( MY_FILE , CPU_TIME_CLOCK ) ;
  48.   TEXT_IO.PUT ( MY_FILE , "        WALL time =" ) ;
  49.   DURATION_IO.PUT ( MY_FILE , CALENDAR.SECONDS(CALENDAR.CLOCK) ) ;
  50.   TEXT_IO.PUT_LINE ( MY_FILE , " seconds." ) ;
  51.   TEXT_IO.CLOSE ( MY_FILE ) ;
  52. end A000054 ;
  53.