I need the fastest routine
- From: Clément Doss <cdoss@xxxxxxxxxx>
- Date: Fri, 04 Jul 2008 18:57:27 -0300
Hi,
I know this is the right place. I'm a just embarrassed to post such a silly question and code. If you could shed some light, I would appreciate very much!!!
In this project, I need to find the max and min integer from an array.
I came up with this code. It seems faster than the others I tried on.
---
procedure MinMaxArray( const aArray : Array of Integer; out aMax, aMin : integer );
var
MaxArray,
MinArray : array[boolean] of integer;
i : integer;
begin
aMax :=0;
aMin :=0;
i:=high( aArray );
if i>=0 then begin
MaxArray[True] := aArray[0];
MinArray[True] := aArray[0];
while i>0 do begin
MaxArray[ aArray[i] > MaxArray[True] ] := aArray[i];
MinArray[ aArray[i] < MinArray[True] ] := aArray[i];
dec(i);
end;
aMax := MaxArray[True];
aMin := MinArray[True];
end;
end;
---
Unfortunately it's not fast enough. I need more speed. I just wanted to be sure this routine is ok, or if there's some tricks to make it faster. If you guys think is a waste of time trying to improve on this routine, then I'll try to optimize other parts of the project.
I appreciate very much your help.
Clément
.
- Follow-Ups:
- Re: I need the fastest routine
- From: Sasa Zeman
- Re: I need the fastest routine
- From: Gilberto Saraiva
- Re: I need the fastest routine
- From: W. van Wezel
- Re: I need the fastest routine
- From: Clément Doss
- Re: I need the fastest routine
- From: Mark Gohara
- Re: I need the fastest routine
- From: Pierre le Riche
- Re: I need the fastest routine
- From: John Herbster
- Re: I need the fastest routine
- From: Nenad Trkulja
- Re: I need the fastest routine
- From: Q Correll
- Re: I need the fastest routine
- Prev by Date: Re: FastMM.. any work in progress?
- Next by Date: Re: I need the fastest routine
- Previous by thread: FastMM.. any work in progress?
- Next by thread: Re: I need the fastest routine
- Index(es):
Relevant Pages
|