Re: I need the fastest routine
- From: Clément Doss <cdoss@xxxxxxxxxx>
- Date: Tue, 15 Jul 2008 14:46:58 -0300
Hello Herby,
I see Double instead of Integer!
What is the history?
I am hired to improve the diagnostic routines of a machine that tests hardware device. The hardware send "arrays" of doubles that must be checked according to their index. That's why I can't order the array. For example, if the Min Max values are in places 11 and 18, then a specific routine must be called.
They had to deal with some internal issues because a larger volume of devices were diagnosed as defective, but in fact were Ok. The former software were taking longer then 5 or 6 minutes to diagnose the component, and this timeout generated a defective flag.
I had little time to digest the routines, and to find IF something were wrong.
The code is very confusing. And I couldn't ask for help from the former developer.
So I decided to make the less possible change to "prove" myself I was right.
When I saw this code :
procedure MinMaxArrayOrig( aArray : Array of Double; out aMinArray,
aMaxArray : Array of double );
var
i : integer;
begin
aMinArray[1]:=aArray[0];
aMaxArray[1]:=aArray[0];
i:=1;
while (i<=high(aArray)) do begin
aMaxArray[ ord( aArray[i] > aMaxArray[1] ) ] := aArray[i];
aMinArray[ ord( aArray[i] < aMinArray[1] ) ] := aArray[i];
inc(i)
end;
end;
I played around with it until I had the idea to change it from Array of Double to Array of Integer. In some of the simpler diagnostic routines, the changes were fairly easy. A simple conversion from Array of Double to Array of Integer and removing MinArray and MaxArray gave me boost I needed. Once I wrote the version with integer and the manager saw the improvements and decided to put some "know" device results as control group.
All tested as expected. Which gave me some extra-time. So I posted my "Original" code here.
With the routines the community wrote. Needless to say that the improvements where even bigger. Which made them think about re-planning their diagnostics routines.
And that's what I'm doing :-)
From a basic component spec I can tell you that the array are not "continuous". I'll try to explain with an example, I place integer just to simplify. The real numbers are doubles:
The device don't return an array like 1 2 3 4 5 6 7 8 9 10.... 5000
but some numbers from 1000..3000, 5000..6000, 6500..6800
In the above example 3001..4999 does not exists, as doesn't 6001..6499.
The larger array I worked with had 5000 elements. But the other said they saw larger.
Anyway thanks for posting your code here. I never would imagine that the routine could be improved that much!!!
The improvement went from almost 5 min (Array of doubles) to 3.5 min (Original post Array of integer) to less then 2 (using the routines posted in this newsgroup).
Very enlightening!
Clément
.
- Follow-Ups:
- Re: I need the fastest routine
- From: Q Correll
- Re: I need the fastest routine
- References:
- I need the fastest routine
- From: Clément Doss
- Re: I need the fastest routine
- From: Nenad Trkulja
- Re: I need the fastest routine
- From: Rudy Velthuis [TeamB]
- Re: I need the fastest routine
- From: Dan Downs
- Re: I need the fastest routine
- From: Rudy Velthuis [TeamB]
- 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]
- Re: I need the fastest routine
- From: Hubert Seidel
- Re: I need the fastest routine
- From: Rudy Velthuis [TeamB]
- Re: I need the fastest routine
- From: Q Correll
- Re: I need the fastest routine
- From: Hubert Seidel
- 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: 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: Clément Doss
- Re: I need the fastest routine
- From: Hubert Seidel
- 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
|