Re: I need the fastest routine
- From: "Hubert Seidel" <nospam@xxxxxxxxxxxxxxxx>
- Date: Sat, 5 Jul 2008 21:57:55 +0200
Hi Rudy,
"Rudy Velthuis [TeamB]" <newsgroups@xxxxxxxxxxxx> schrieb im Newsbeitrag
news:xn0fsbtfwfpwjp100rnewsgroups@xxxxxxxxxxxxxxx
Rudy Velthuis [TeamB] wrote:....
I just coded all three versions in one program. Your code and my first
code produce exactly the same machine code. Not one single instruction
is different.
(sorry, my english is not so good, i try it :)
i moved the access from parameters to local variables and .
A Test with three arrays (first has 50000 random-integers +/- 25000, next
has linear up 0,1,2,3,4,etc till 49999. and the last has linear down
0,-1,-2,-3 etc. till -49999) used per round averaged 10 cpu-clocks on
PIII-Cpu:
(*
procedure MinMaxArray(const aArray:array of integer; out aMax,
aMin:integer);
var // averaged 11 clocks per roundtrip
i:integer;
begin
aMax := aArray[Low(aArray)];
aMin := aMax;
for i := Low(aArray) + 1 to High(aArray) do
begin
if (aArray[i]<aMin) then aMin:=aArray[i];
if (aArray[i]>aMax) then aMax:=aArray[i];
end;
end;
*)
procedure MinMaxArray(const aArray:array of integer; out aMax,
aMin:integer);
var // averaged 10 clocks per roundtrip = 10% faster than above
i,mi,ma:integer;
begin
ma := aArray[Low(aArray)];
mi := ma;
for i := Low(aArray) + 1 to High(aArray) do
begin
if (aArray[i]<mi) then mi:=aArray[i];
if (aArray[i]>ma) then ma:=aArray[i];
end;
aMax := ma;
aMin := mi;
end;
mfg.
Herby
--
http://www.hubert-seidel.de
.
- Follow-Ups:
- Re: I need the fastest routine
- From: Q Correll
- Re: I need the fastest routine
- From: Rudy Velthuis [TeamB]
- Re: I need the fastest routine
- References:
- I need the fastest routine
- From: Clément Doss
- Re: I need the fastest routine
- From: Q Correll
- Re: I need the fastest routine
- From: Clément Doss
- Re: I need the fastest routine
- From: Q Correll
- Re: I need the fastest routine
- From: Stig Johansen
- Re: I need the fastest routine
- From: Rudy Velthuis [TeamB]
- Re: I need the fastest routine
- From: Rudy Velthuis [TeamB]
- I need the fastest routine
- Prev by Date: Re: I need the fastest routine
- Next by Date: Re: I need the fastest routine
- Previous by thread: Re: I need the fastest routine
- Next by thread: Re: I need the fastest routine
- Index(es):
Relevant Pages
|