Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mdot
Message
De
07/01/2005 09:40:13
 
 
À
07/01/2005 09:19:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: Mdot
Divers
Thread ID:
00974967
Message ID:
00975075
Vues:
23
>>Hi All,
>>
>>I am trying to confirm a point iro the working of mdot: if I have a file with 10 fields and 100 records and I need to scan through this file and inside my loop I reference 10 variables then will VFP need to lookup and resolve 10 vars x 10 fields x 100 recs = 10,000 field/variable references? Would using mdot avoid the need to perform 10,000 field/vars lookups?
>
>Hi Jos:
>The answer is simple: YES.
>
>
>Time = O(1 + K1* FCOUNT()* NVariableWithoutMdotReads)
>
>
>Another case is this: objRef.Property read ( Property is a random choice from AMEMBERS )
>
>Time = O(1 + K2 * AUSED()* NObjRefWithOneDotReads + K3 * NObjRefReads * AMEMBERS(ObjRef))
>
>
>Fabio

Hi Fabio, Hilmar, and all,

Well I used to be in the camp where I did not use mdot at all (forgive me Fabio :) and believed that mdot would not make a significant difference to performance. I always use field and variable naming conventions to avoid field/variable conflicts and have never had a problem with that issue, ever.

However, the recent discussion on mdot and having some free time on my hands <g> made me spend a few hours reworking some intense processing code:

Background:

1) I have one app which draws charts of various data. The chart data is stored in a file of about 10 fields. This data is read into a temporary cursor where several manipulations can be performed on it. The data points for a chart can easily have 1000, 5000, or more points.

2) The temporary cursor can then be further processed in order to calculate other data from the original data points. This requires working through the cursor, sometimes more than once.

3) Therefore a temp data cursor of 100 fields and 1000 records of data points and being processed for further calculations involving easily 20, 30, or more variables works out to 100f x 1000r x 30v = 3,000,000 field/variable lookups. Hence my original question.


I changed all this code to use mdot. The result is that charts that took 1 to 2 seconds to draw are now drawing in as little as half the time. The use of mdot in these charting routines has resulted in a speed improvement of between 30% and 100% depending on the complexity of the chart involved.

Although in absolue terms it means only a 0.5 or 1.0 second improvement per chart the percentage improvement is fantastic. And when a user is drawing numerous charts, including charts that automatically refresh as new data arrives, this is a very signifcant improvement.

My opinion; if you have loop code where the number of fields times the number of records being processed times the number of variables in the loop can be a significant number then mdot is essential for speed if nothing else :)

PS: Fabio I appreciate your position that mdot is primarily a correct coding technique with secondary benefit being a potential speed improvement. But old habits die hard :)
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform