home *** CD-ROM | disk | FTP | other *** search
-
- -- PERFORMANCE MEASUREMENT : exception raise and handle time
- -- exception in procedure
-
- package EXCEPT_PACK_2 is
-
- MY_EXCEPTION : exception ;
- SWITCH : BOOLEAN ; -- controls return or raise exception
-
- procedure PROC_1 ( SWITCH : BOOLEAN ) ; -- either returns or raises exception
-
- end EXCEPT_PACK_2 ;
-
- with EXCEPT_PACK_2 ; use EXCEPT_PACK_2 ;
- with REMOTE_GLOBAL ; use REMOTE_GLOBAL ; -- control optimization
- with ITERATION ; -- obtain stable measurement
- with PIWG_IO ; -- output results
-
- procedure E000002 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
-
- 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
- --
- if A_ONE = 2 then
- SWITCH := TRUE ;
- else
- SWITCH := FALSE ;
- end if ;
-
- ITERATION.START_CONTROL ;
- for J in 1 .. ITERATION_COUNT loop
- GLOBAL := 0 ;
- for INSIDE_LOOP in 1 .. CHECK_TIMES loop
- -- this has control global increment and call inside
- begin
- PROC_1 ( SWITCH ) ; -- FALSE no exception raised
- exception
- when MY_EXCEPTION =>
- null ;
- end ;
- end loop ;
- end loop ;
- ITERATION.STOP_CONTROL ( GLOBAL , CHECK_TIMES ) ;
-
- --
- -- Test loop
- --
- -- establish exception raise and handle time
-
- if A_ONE = 1 then
- SWITCH := TRUE ;
- else
- SWITCH := FALSE ;
- end if ;
-
- ITERATION.START_TEST ;
- for J in 1 .. ITERATION_COUNT loop
- GLOBAL := 0 ;
- for INSIDE_LOOP in 1 .. CHECK_TIMES loop
- -- this has control global increment and call inside
- begin
- PROC_1 ( SWITCH ) ; -- TRUE exception will be raised
- exception
- when MY_EXCEPTION =>
- null ;
- end ;
- 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 ( "E000002" , "Exception" ,
- CPU_TIME , WALL_TIME , ITERATION_COUNT ,
- " Exception raise and handle timing measurement" ,
- " when exception is in a procedure in a package" ,
- " " ) ;
- end E000002 ;
-
- with REMOTE_GLOBAL ; use REMOTE_GLOBAL ;
- package body EXCEPT_PACK_2 is -- compare to E000001, diff is propegation
-
- procedure PROC_1 ( SWITCH : BOOLEAN ) is
- begin
- if SWITCH then
- GLOBAL := GLOBAL + 1 ;
- REMOTE ;
- raise MY_EXCEPTION ;
- else
- GLOBAL := GLOBAL + 1 ;
- REMOTE ;
- return ;
- end if ;
- exception
- when PROGRAM_ERROR =>
- PROC_1 ( SWITCH ) ;
- end PROC_1 ;
-
- end EXCEPT_PACK_2 ;
-