home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / piwg / a000098.ada < prev    next >
Encoding:
Text File  |  1988-05-03  |  2.8 KB  |  86 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 CASE_COUNT copies of A 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 A000098 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.   CASE_COUNT : constant := <number of repetitions> ;
  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.     GLOBAL := GLOBAL / CASE_COUNT ;
  67.     ITERATION.STOP_TEST ( GLOBAL , CHECK_TIMES ) ;
  68.     ITERATION.TEST_STABLE ( ITERATION_COUNT , STABLE ) ;
  69.     exit when STABLE ;
  70.   end loop ;
  71. --
  72.   ITERATION.FEATURE_TIMES ( CPU_TIME , WALL_TIME ) ;
  73.   CPU_TIME := DURATION ( CPU_TIME / CASE_COUNT ) ;
  74.   WALL_TIME := DURATION ( WALL_TIME / CASE_COUNT ) ;
  75.  
  76. --
  77. -- Printout
  78. --
  79.   PIWG_IO.PIWG_OUTPUT ( "A000098" , "Procedure" ,
  80.                         CPU_TIME , WALL_TIME , ITERATION_COUNT ,
  81.      " Three lines of comments explaining what was measured " ,
  82.      " more comments " ,
  83.      " more comments" ) ;
  84.  
  85. end A000098 ;
  86.