Re: I need the fastest routine



Hi Clément,

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.

I haven't benchmarked it, but I reckon the routine below should be faster:

procedure MinMaxArray(const aArray: array of Integer; out aMax, aMin: Integer);
var
LInd, LTempMin, LTempMax, LArrVal: Integer;
begin
LTempMin := MaxInt;
LTempMax := MinInt;
for LInd := 0 to High(aArray) do
begin
{Get the array value}
LArrVal := aArray[LInd];
{Update the minimum}
LTempMin := LArrVal + ((-Ord(LTempMin < LArrVal))
and (LTempMin - LArrVal));
{Update the maximum}
LTempMax := LArrVal + ((-Ord(LTempMax > LArrVal))
and (LTempMax - LArrVal));
end;
aMin := LTempMin;
aMax := LTempMax;
end;

Regards,
Pierre
.



Relevant Pages

  • Re: I need the fastest routine
    ... out aMax, aMin: Integer); ... {Get the array value} ... and (LTempMin - LArrVal)); ...
    (borland.public.delphi.language.basm)
  • Re: I need the fastest routine
    ... out aMax, aMin: Integer); ... and (LTempMin - LArrVal)); ... -- Seymoure Cray when asked what CAD tools he used ...
    (borland.public.delphi.language.basm)
  • Re: I need the fastest routine
    ... procedure MinMaxArray(const aArray: Array of Integer; out aMax, ... aMin: integer); ... var p: pinteger; ...
    (borland.public.delphi.language.basm)
  • Re: I need the fastest routine
    ... procedure MinMaxArray(const aArray: Array of Integer; out aMax, aMin: ... var i: integer; ...
    (borland.public.delphi.language.basm)
  • Re: I need the fastest routine
    ... procedure MinMaxArray(const aArray: Array of Integer; out aMax, aMin: integer); ...
    (borland.public.delphi.language.basm)