From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Performance of element access in Vector
Date: Fri, 23 Jan 2009 18:30:22 +0100
Date: 2009-01-23T18:30:23+01:00 [thread overview]
Message-ID: <4979feaf$0$31870$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <6tu43dFcibgkU1@mid.individual.net>
Alex R. Mosteo schrieb:
> Georg Bauhaus wrote:
>
>> Maciej Sobczak schrieb:
>>
>>> The problem here is that the compiler does not inline Update_Element/
>>> Query_Element callbacks. Safety and performance are not in conflict
>>> here, it is just a quality of implementation issue.
>>> You can have both.
>> FWIW, if Iterate/Process is made a generic procedure as
>> in the original AI-302, and Increment is made a library
>> level procedure, then GNAT confirms, in a sense,
>> that there might be a quality of implementation issue:
>>
>> raw array : 00:00:29.78
>> raw array process : 00:01:06.74
>> raw array generic : 00:00:29.78
>
> Do you mean, IIUC, that if 'process' where properly inlined, the timing
> would be same for the three instances? That would be nice.
The third line seems to indicate the possibility
of inlining, provided nothing else gets in the
way---in the case of 'Access to procedure; can't say.
Complete example with Increment made a library level
procedure for all three methods:
-- 8<--
procedure Increment (I : in out Integer);
pragma Inline(Increment);
with Ada.Calendar.Formatting;
with Ada.Text_IO;
with Increment;
procedure Test_P is
Iterations: constant := 10_000;
type Int_Array is array(Positive range <>) of Integer;
Start : Ada.Calendar.Time;
Stop : Ada.Calendar.Time;
use type Ada.Calendar.Time;
procedure Test_0A (Container: in out Int_Array;
Process: not null access procedure (Element: in
out Integer)) is
begin
Start := Ada.Calendar.Clock;
for J in 1 .. Iterations loop
for Index in Container'Range loop
Process(Container(Index));
end loop;
end loop;
Stop := Ada.Calendar.Clock;
Ada.Text_IO.Put_Line
("raw array process : " &
Ada.Calendar.Formatting.Image (Stop - Start, True));
end Test_0A;
generic
with procedure Process (Element: in out Integer);
procedure Test_0B (Container: in out Int_Array);
procedure Test_0B (Container: in out Int_Array) is
begin
Start := Ada.Calendar.Clock;
for J in 1 .. Iterations loop
for Index in Container'Range loop
Process(Container(Index));
end loop;
end loop;
Stop := Ada.Calendar.Clock;
Ada.Text_IO.Put_Line
("raw array generic : " &
Ada.Calendar.Formatting.Image (Stop - Start, True));
end Test_0B;
procedure Test_0(Container: in out Int_Array) is
begin
Start := Ada.Calendar.Clock;
for J in 1 .. Iterations loop
for I in Container'range loop
Container(I) := Container(I) + 1;
end loop;
end loop;
Stop := Ada.Calendar.Clock;
Ada.Text_IO.Put_Line
("raw array : " &
Ada.Calendar.Formatting.Image (Stop - Start, True));
end Test_0;
Z: Int_Array(Positive range 1 .. 1_000_000);
begin
Test_0(Z);
Test_0A(Z, Increment'Access);
declare
procedure Test_G is new Test_0B(Process => Increment);
begin
Test_G(Z);
end;
end Test_P;
procedure Increment (I : in out Integer) is
begin
I := I + 1;
end Increment;
prev parent reply other threads:[~2009-01-23 17:30 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-18 21:42 Performance of element access in Vector Maciej Sobczak
2009-01-19 0:03 ` george.priv
2009-01-19 3:23 ` george.priv
2009-01-19 11:25 ` Georg Bauhaus
2009-01-19 16:32 ` (see below)
2009-01-20 2:17 ` Randy Brukardt
2009-01-20 8:03 ` Maciej Sobczak
2009-01-20 8:26 ` Dmitry A. Kazakov
2009-01-20 22:07 ` george.priv
2009-01-21 8:52 ` Maciej Sobczak
2009-01-21 19:25 ` george.priv
2009-01-22 10:01 ` Georg Bauhaus
2009-01-22 12:43 ` Maciej Sobczak
2009-01-22 13:52 ` george.priv
2009-01-21 8:59 ` Dmitry A. Kazakov
2009-01-21 9:19 ` Maciej Sobczak
2009-01-21 10:19 ` Dmitry A. Kazakov
2009-01-21 13:14 ` Maciej Sobczak
2009-01-21 19:00 ` Dmitry A. Kazakov
2009-01-21 13:22 ` Georg Bauhaus
2009-01-23 14:56 ` Alex R. Mosteo
2009-01-20 23:01 ` Randy Brukardt
2009-01-21 9:15 ` Maciej Sobczak
2009-01-21 18:08 ` Georg Bauhaus
2009-01-23 14:55 ` Alex R. Mosteo
2009-01-23 17:30 ` Georg Bauhaus [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox