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

  1. -- PERFORMANCE MEASUREMENT : task creation and termination time
  2. --                           1 task no entry
  3. --                           task local in declare block, no select
  4.  
  5. with REMOTE_GLOBAL ; use REMOTE_GLOBAL ; -- control optimization
  6. with ITERATION ; -- obtain stable measurement
  7. with PIWG_IO ; -- output results
  8.  
  9. procedure C000003 is  -- main procedure to execute
  10.  
  11.   CPU_TIME : DURATION ; -- CPU time for one feature execution
  12.   WALL_TIME : DURATION ; -- WALL time for one feature execution
  13.   CHECK_TIMES : constant := 100 ; -- inside loop count and check
  14.   ITERATION_COUNT : INTEGER ; -- set and varied by ITERATION package
  15.   STABLE : BOOLEAN ; -- true when measurement stable
  16.  
  17. begin
  18.  
  19.   ITERATION.START_CONTROL ;  -- dummy to bring in pages on some machines
  20.  
  21.   delay 0.5 ;  -- wait for stable enviornment on some machines
  22.  
  23.   ITERATION.INITIALIZE ( ITERATION_COUNT ) ;
  24.  
  25.   loop  -- until stable measurement, ITERATION_COUNT increases each time
  26.  
  27. --
  28. -- Control loop
  29. --
  30.     ITERATION.START_CONTROL ;
  31.     for J in 1 .. ITERATION_COUNT loop
  32.       GLOBAL := 0 ;
  33.       for INSIDE_LOOP in 1 .. CHECK_TIMES loop
  34.         GLOBAL := GLOBAL + A_ONE ; 
  35.         REMOTE ;                   
  36.       end loop ;
  37.     end loop ;
  38.     ITERATION.STOP_CONTROL ( GLOBAL , CHECK_TIMES ) ;
  39.  
  40. --
  41. -- Test loop
  42. --
  43. -- establish task create and terminate time
  44.  
  45.     ITERATION.START_TEST ;
  46.     for J in 1 .. ITERATION_COUNT loop
  47.       GLOBAL := 0 ;
  48.       for INSIDE_LOOP in 1 .. CHECK_TIMES loop
  49.         declare
  50. --           this creates the task, runs task to completion and terminates
  51.           task T1 is
  52.           end T1 ;
  53.  
  54.           task body T1 is
  55.           begin
  56.             GLOBAL := GLOBAL + A_ONE ;
  57.             REMOTE ;
  58.           end T1 ;
  59.         begin
  60.           null ;
  61.         end ;
  62.       end loop ;
  63.     end loop ;
  64.     ITERATION.STOP_TEST ( GLOBAL , CHECK_TIMES ) ;
  65.     ITERATION.TEST_STABLE ( ITERATION_COUNT , STABLE ) ;
  66.     exit when STABLE ;
  67.   end loop ;
  68. --
  69.   ITERATION.FEATURE_TIMES ( CPU_TIME , WALL_TIME ) ;
  70.  
  71. --
  72. -- Printout
  73. --
  74.   PIWG_IO.PIWG_OUTPUT ( "C000003" , "Tasking" ,
  75.                         CPU_TIME , WALL_TIME , ITERATION_COUNT ,
  76.      " Task create and terminate time measurement " ,
  77.      " Task is in declare block of main procedure " ,
  78.      " one task, no entries, task is in the loop" ) ;
  79.  
  80. end C000003 ;
  81.