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

  1. -- This is a sample skeleton test
  2. -- It is based on the concept of having a control loop
  3. -- and a test loop. The test loop has everything the control loop has
  4. -- plus one feature to be measured.
  5. -- The time reported for the feature is based on many iterations.
  6. -- The measurement auto calibrates using the ITERATION package.
  7. -- The time calculation is a difference of a difference and thus
  8. -- removes measurement bias from many sources.
  9.  
  10.  
  11. -- PERFORMANCE MEASUREMENT : Comment here and at bottom on what measured
  12. --                           more comments
  13. --                           more comments
  14.  
  15. with REMOTE_GLOBAL ; use REMOTE_GLOBAL ; -- control optimization
  16. with ITERATION ; -- obtain stable measurement
  17. with PIWG_IO ; -- output results
  18.  
  19. procedure A000099 is  -- main procedure to execute
  20.  
  21.   CPU_TIME : DURATION ; -- CPU time for one feature execution
  22.   WALL_TIME : DURATION ; -- WALL time for one feature execution
  23.   CHECK_TIMES : constant := 100 ; -- inside loop count and check
  24.   ITERATION_COUNT : INTEGER ; -- set and varied by ITERATION package
  25.   STABLE : BOOLEAN ; -- true when measurement stable
  26.  
  27. --
  28. -- More declarations may go here
  29. --
  30.  
  31. begin
  32.  
  33.   ITERATION.START_CONTROL ;  -- dummy to bring in pages on some machines
  34.  
  35.   delay 0.5 ;  -- wait for stable enviornment on some machines
  36.  
  37.   ITERATION.INITIALIZE ( ITERATION_COUNT ) ;
  38.  
  39.   loop  -- until stable measurement, ITERATION_COUNT increases each time
  40.  
  41. --
  42. -- Control loop
  43. --
  44.     ITERATION.START_CONTROL ;
  45.     for J in 1 .. ITERATION_COUNT loop
  46.       GLOBAL := 0 ;
  47.       for INSIDE_LOOP in 1 .. CHECK_TIMES loop
  48.         GLOBAL := GLOBAL + A_ONE ; -- typical control loop is
  49.         REMOTE ;                   -- these two statements
  50.       end loop ;
  51.     end loop ;
  52.     ITERATION.STOP_CONTROL ( GLOBAL , CHECK_TIMES ) ;
  53.  
  54. --
  55. -- Test loop
  56. --
  57.     ITERATION.START_TEST ;
  58.     for J in 1 .. ITERATION_COUNT loop
  59.       GLOBAL := 0 ;
  60.       for INSIDE_LOOP in 1 .. CHECK_TIMES loop
  61. --      PROC_0 ;  -- this has control global increment and call inside
  62.                   -- example of testing a feature in the test loop
  63.         null;
  64.       end loop ;
  65.     end loop ;
  66.     ITERATION.STOP_TEST ( GLOBAL , CHECK_TIMES ) ;
  67.     ITERATION.TEST_STABLE ( ITERATION_COUNT , STABLE ) ;
  68.     exit when STABLE ;
  69.   end loop ;
  70. --
  71.   ITERATION.FEATURE_TIMES ( CPU_TIME , WALL_TIME ) ;
  72.  
  73. --
  74. -- Printout
  75. --
  76.   PIWG_IO.PIWG_OUTPUT ( "A000099" , "Procedure" ,
  77.                         CPU_TIME , WALL_TIME , ITERATION_COUNT ,
  78.      " Three lines of comments explaining what was measured " ,
  79.      " more comments " ,
  80.      " more comments" ) ;
  81.  
  82. end A000099 ;
  83.