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

  1.  
  2. -- PERFORMANCE MEASUREMENT : Minimum entry call and return time
  3. --                           1 task 1 entry
  4. --                           no select
  5. --
  6. --     This ia a version on T000001 without the " do .. end ; "
  7. --     This will not work in most implementations because the checking
  8. --     to be sure the task executions have completed fails.
  9. --     If this test does run, please report it if the times differ
  10. --     from T000001.
  11.  
  12. with REMOTE_GLOBAL ; use REMOTE_GLOBAL ; -- control optimization
  13. with ITERATION ; -- obtain stable measurement
  14. with PIWG_IO ; -- output results
  15.  
  16. procedure T000007 is  -- main procedure to execute
  17.  
  18.   CPU_TIME : DURATION ; -- CPU time for one feature execution
  19.   WALL_TIME : DURATION ; -- WALL time for one feature execution
  20.   CHECK_TIMES : constant := 100 ; -- inside loop count and check
  21.   ITERATION_COUNT : INTEGER ; -- set and varied by ITERATION package
  22.   STABLE : BOOLEAN ; -- true when measurement stable
  23.  
  24. --
  25.   task T1 is
  26.     entry E1 ;
  27.   end T1 ;
  28.  
  29.   task body T1 is
  30.   begin
  31.     loop
  32.       accept E1 ;
  33.       GLOBAL := GLOBAL + A_ONE ;
  34.       REMOTE ;
  35.     end loop ;
  36.   end ;
  37.  
  38. begin
  39.  
  40.   ITERATION.START_CONTROL ;  -- dummy to bring in pages on some machines
  41.  
  42.   delay 0.5 ;  -- wait for stable enviornment on some machines
  43.  
  44.   ITERATION.INITIALIZE ( ITERATION_COUNT ) ;
  45.  
  46.   loop  -- until stable measurement, ITERATION_COUNT increases each time
  47.  
  48. --
  49. -- Control loop
  50. --
  51.     ITERATION.START_CONTROL ;
  52.     for J in 1 .. ITERATION_COUNT loop
  53.       GLOBAL := 0 ;
  54.       for INSIDE_LOOP in 1 .. CHECK_TIMES loop
  55.         GLOBAL := GLOBAL + A_ONE ; 
  56.         REMOTE ;                   
  57.       end loop ;
  58.     end loop ;
  59.     ITERATION.STOP_CONTROL ( GLOBAL , CHECK_TIMES ) ;
  60.  
  61. --
  62. -- Test loop
  63. --
  64.     ITERATION.START_TEST ;
  65.     for J in 1 .. ITERATION_COUNT loop
  66.       GLOBAL := 0 ;
  67.       for INSIDE_LOOP in 1 .. CHECK_TIMES loop
  68.         T1.E1 ; -- this has control global increment and call inside
  69.       end loop ;
  70.     end loop ;
  71.     ITERATION.STOP_TEST ( GLOBAL , CHECK_TIMES ) ;
  72.     ITERATION.TEST_STABLE ( ITERATION_COUNT , STABLE ) ;
  73.     exit when STABLE ;
  74.   end loop ;
  75. --
  76.   ITERATION.FEATURE_TIMES ( CPU_TIME , WALL_TIME ) ;
  77.  
  78. --
  79. -- Printout
  80. --
  81.    PIWG_IO.PIWG_OUTPUT ( "T000007" , "Tasking" ,
  82.                         CPU_TIME , WALL_TIME , ITERATION_COUNT ,
  83.      " Minimum rendezvous, entry call and return time " ,
  84.      " 1 task 1 entry " ,
  85.      " no select " ) ;
  86.  
  87.   abort T1 ;
  88.  
  89. end T000007 ;
  90.