From: Laurent.Guerby@enst-bretagne.fr (Laurent Guerby)
Subject: Performance issue
Date: 1996/04/03
Date: 1996-04-03T00:00:00+00:00 [thread overview]
Message-ID: <4xrau69js6.fsf@leibniz.enst-bretagne.fr> (raw)
-- 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)
next reply other threads:[~1996-04-03 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-04-03 0:00 Laurent Guerby [this message]
1996-04-03 0:00 ` Performance issue Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox