home *** CD-ROM | disk | FTP | other *** search
-
- -- PERFORMANCE MEASUREMENT : Elaboration, allocation and freeing of
- -- record containing a dynamic array
-
- package DYNAMIC_ARRAY_PACKAGE_3 is
- DYNAMIC_SIZE : INTEGER ;
- type DYNAMIC_ARRAY is array ( INTEGER range <> ) of INTEGER ;
- type DYNAMIC_RECORD ( SIZE : INTEGER ) is
- record
- INSIDE_ARRAY : DYNAMIC_ARRAY ( 1..SIZE ) ;
- end record ;
- LOCAL_ARRAY : DYNAMIC_RECORD ( 1000 ) ;
- procedure PROC_CONTROL ;
- procedure PROC_TEST ;
- end DYNAMIC_ARRAY_PACKAGE_3 ;
-
- with DYNAMIC_ARRAY_PACKAGE_3 ; use DYNAMIC_ARRAY_PACKAGE_3 ;
- with REMOTE_GLOBAL ; use REMOTE_GLOBAL ; -- control optimization
- with ITERATION ; -- obtain stable measurement
- with PIWG_IO ; -- output results
-
- procedure D000003 is -- main procedure to execute
- CPU_TIME : DURATION ; -- CPU time for one feature execution
- WALL_TIME : DURATION ; -- WALL time for one feature execution
- CHECK_TIMES : constant := 100 ; -- inside loop count and check
- ITERATION_COUNT : INTEGER ; -- set and varied by ITERATION package
- STABLE : BOOLEAN ; -- true when measurement stable
-
- begin
-
- DYNAMIC_SIZE := 1000 ;
-
- ITERATION.START_CONTROL ; -- dummy to bring in pages on some machines
-
- delay 0.5 ; -- wait for stable enviornment on some machines
-
- ITERATION.INITIALIZE ( ITERATION_COUNT ) ;
-
- loop -- until stable measurement, ITERATION_COUNT increases each time
-
- --
- -- Control loop
- --
- ITERATION.START_CONTROL ;
- for J in 1 .. ITERATION_COUNT loop
- GLOBAL := 0 ;
- for INSIDE_LOOP in 1 .. CHECK_TIMES loop
- PROC_CONTROL ;
- end loop ;
- end loop ;
- ITERATION.STOP_CONTROL ( GLOBAL , CHECK_TIMES ) ;
-
-
- --
- -- Test loop
- --
-
- ITERATION.START_TEST ;
- for J in 1 .. ITERATION_COUNT loop
- GLOBAL := 0 ;
- for INSIDE_LOOP in 1 .. CHECK_TIMES loop
- PROC_TEST ; -- this has control global increment and call inside
- end loop ;
- end loop ;
- ITERATION.STOP_TEST ( GLOBAL , CHECK_TIMES ) ;
- ITERATION.TEST_STABLE ( ITERATION_COUNT , STABLE ) ;
- exit when STABLE ;
- end loop ;
- --
- ITERATION.FEATURE_TIMES ( CPU_TIME , WALL_TIME ) ;
-
- --
- -- Printout
- --
- PIWG_IO.PIWG_OUTPUT ( "D000003" , "Allocation" ,
- CPU_TIME , WALL_TIME , ITERATION_COUNT ,
- " Dynamic record allocation and deallocation time measurement " ,
- " elaborating, allocating and deallocating " ,
- " record containing a dynamic array of 1000 integers " ) ;
- end D000003 ;
-
- with REMOTE_GLOBAL ; use REMOTE_GLOBAL ;
- package body DYNAMIC_ARRAY_PACKAGE_3 is
-
- procedure PROC_CONTROL is
- begin
- GLOBAL := GLOBAL + A_ONE ;
- LOCAL_ARRAY.INSIDE_ARRAY ( GLOBAL ) := GLOBAL ;
- REMOTE ;
- GLOBAL := LOCAL_ARRAY.INSIDE_ARRAY ( GLOBAL ) ;
- end ;
-
- procedure PROC_TEST is
- PROC_ARRAY : DYNAMIC_RECORD ( DYNAMIC_SIZE ) ;
- begin
- GLOBAL := GLOBAL + A_ONE ;
- PROC_ARRAY.INSIDE_ARRAY ( GLOBAL ) := GLOBAL ;
- REMOTE ;
- GLOBAL := PROC_ARRAY.INSIDE_ARRAY ( GLOBAL ) ;
- end PROC_TEST ;
-
- end DYNAMIC_ARRAY_PACKAGE_3 ;
-