From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ef051e30307e2ff9,start X-Google-Attributes: gid103376,public From: Laurent.Guerby@enst-bretagne.fr (Laurent Guerby) Subject: Performance issue Date: 1996/04/03 Message-ID: <4xrau69js6.fsf@leibniz.enst-bretagne.fr>#1/1 X-Deja-AN: 145518570 distribution: world sender: guerby@leibniz.enst-bretagne.fr content-type: text/plain; charset=US-ASCII organization: Telecom Bretagne mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-04-03T00:00:00+00:00 List-Id: -- Laurent Guerby, 1996-04-03 -- Simple test to measure the speed improvement between GNAT 3.03 and GNAT -- 3.04 for "zero cost exception handling" (no more setjmps). -- Here are the result on Solaris 2.4 on a SS4, -- -- with GNAT 3.03 : -- $ gnatmake perf_exception.adb -cargs -O2 -- gcc -c -O2 perf_exception.adb -- gnatbind perf_exception.ali -- gnatbl perf_exception.ali -linkonly -- $ /bin/time perf_exception -- real 6:36.8 (396.8s) -- user 1:58.5 (118.5s) -- sys 4:28.9 (268.9s) -- (Note that you can easily get +/-30s on these numbers since you're -- relying a lot on the system). -- -- with GNAT 3.04 : -- $ gnatmake perf_exception.adb -cargs -O2 -- gcc -c -O2 perf_exception.adb -- gnatbind -x perf_exception.ali -- gnatlink perf_exception.ali -- $ /bin/time perf_exception -- real 12.6 ( 12.6s) -- user 12.2 ( 12.2s) -- sys 0.0 ( 0.0s) -- -- Speedup = (118.5+268.9) / (12.2+0.0) = 31.7 (>= 20) -- Hum, one order of magnitude faster ;-). procedure Perf_Exception is pragma Suppress (All_Checks); -- We don't want to measure range or overflow checks performance. E : exception; Number_Of_E : constant := 10; Number_Of_Inc : constant := 10_000_000; -- With this configuration, we just measure the cost of entering a -- block with an exception handler, not the performance of exception -- handling by itself. Swap the numbers if you want a "naive" measure -- of exceptiom handling performance. E_Count : Natural := 0; Inc_Count : Natural := 0; begin -- The following loop raises Number_Of_E times E, and the block -- statement is executed Number_Of_E + Number_Of_Inc times, counting -- the number of "Inc" and "E", to defeat compiler optimization. for I in 1 .. Number_Of_E + Number_Of_Inc loop begin if I > Number_Of_Inc then raise E; else Inc_Count := Inc_Count + 1; end if; exception when E => E_Count := E_Count + 1; end; end loop; -- Simple coherence check (the result of our useful computation ;-). if E_Count /= Number_Of_E or Inc_Count /= Number_Of_Inc then raise Program_Error; end if; end Perf_Exception; -- -- Laurent Guerby, student at Telecom Bretagne (France), Team Ada -- "Use the Source, Luke. The Source will be with you, always (GPL)" -- http://www-eleves.enst-bretagne.fr/~guerby/ (GATO Project) -- Try GNAT, the GNU Ada 95 compiler (ftp://cs.nyu.edu/pub/gnat)