Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is scatter name loTemp slower than scatter memvar?
Message
 
 
À
17/08/2001 02:08:45
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00544355
Message ID:
00545252
Vues:
25
Thanks, Walter. After I converted it back to using memvars, dropped the indexes, changed append blank+gather to insert into and made few other small improvements (like changed seek to indexseek and use outtable in the order already), it now seems to work 100 times faster than before.

Thanks again.

>Nadya,
>
>Your observations are correct. I've had simular experience with the performance difference between SCATTER NAME and SCATTER MEMVAR. In my database conversion programs I used to use SCATTER NAME. It runned slowly. With SCATTER MEMVAR, the whole routine was about three, four times faster. I've not benchmarked (exact calculation) the performance difference, but I'll guess it must be a factor 10 or something. Though with SCATTER MEMVAR you'll lost some encapsulation, I thought, for performance reasons, it is better to revert to it.
>
>Walter,
>
>
>>I have a program in which I scan through quite a long file (200000 recs and more) and perform some calculations. Here is the code fragment from this program:
>>
>>local lcccTown, lnRank, lcFieldsAdd
>>k=0
>>do while k>     k=m.k+1 && Increment count
>>     for i=m.lnStart to m.lnEnd step m.lnStep && Two ranking (by Num and by Vol)
>>          select ('curAll'+transform(m.k))
>>          set order to tag tag(m.i) descending && Reverse order NumAll, VolAll, NumPur, etc.
>>          lcccTown=ccode+town
>>          lnRank=0
>>          scan for !m.llHalt
>>               lnCount=m.lnCount+1
>>
>>** Update status message
>>               if mod(m.lnCount,100) = 0
>>                    set message to 'Record # '+transform(m.lnCount)+m.lcMsgTail
>>               endif
>>
>>** Update thermometer
>>               if mod(m.lnCount,m.lnUpdateNumber) = 0
>>                    loTherm.update(m.lnCount)
>>               endif
>>
>>               scatter name loTemp
>>               with loTemp
>>                    lcSearchExpr=.ccode+.town
>>                    if seek(m.lcSearchExpr, 'curSumAll'+transform(m.k), 'cctown')
>>                         select ('curSumAll'+transform(m.k))
>>                         do case
>>                         case m.i=1 && NumAll
>>                              lcExt='All'
>>                              lnTotal=YtdNumAll && for all lenders in this town
>>                              if m.lnTotal>0 && Should be always >0
>>                                   .MksNumAll=round((.YtdNumAll/m.lnTotal)*100,2)
>>                              else
>>                                   .MksNumAll=0
>>                              endif
>>                              lcFieldsAdd='MksNumAll, RankNumAll'
>>
>>                         case m.i=2 && VolAll
>>                              lcExt='All'
>>                              lnTotal=YtdVolAll && for all lenders in this town
>>                              if m.lnTotal>0 && Should be always >0
>>                                   .MksVolAll=round((.YtdVolAll/m.lnTotal)*100,2)
>>                              else
>>                                   .MksVolAll=0
>>                              endif
>>                              lcFieldsAdd='MksVolAll, RankVolAll'
>>
>>                         case m.i=3 && NumPur
>>                              lcExt='Pur'
>>                              lnTotal=YtdNumPur && for all lenders in this town
>>                              if m.lnTotal>0 && Should be always >0
>>                                   .MksNumPur=round((.YtdNumPur/m.lnTotal)*100,2)
>>                              else
>>                                   .MksNumPur=0
>>                              endif
>>                              lcFieldsAdd='MksNumPur, RankNumPur'
>>
>>                         case m.i=4 && VolPur
>>                              lcExt='Pur'
>>                              lnTotal=YtdVolPur && for all lenders in this town
>>                              if m.lnTotal>0 && Should be always >0
>>                                   .MksVolPur=round((.YtdVolPur/m.lnTotal)*100,2)
>>                              else
>>                                   .MksVolPur=0
>>                              endif
>>                              lcFieldsAdd='MksVolPur, RankVolPur'
>>
>>                         case m.i=5 && NumRef
>>                              lcExt='Ref'
>>                              lnTotal=YtdNumRef && for all lenders in this town
>>                              if m.lnTotal>0 && Should be always >0
>>                                   .MksNumRef=round((.YtdNumRef/m.lnTotal)*100,2)
>>                              else
>>                                   .MksNumRef=0
>>                              endif
>>                              lcFieldsAdd='MksNumRef, RankNumRef'
>>
>>                         case m.i=6 && VolRef
>>                              lcExt='Ref'
>>                              lnTotal=YtdVolRef && for all lenders in this town
>>                              if m.lnTotal>0 && Should be always >0
>>                                   .MksVolRef=round((.YtdVolRef/m.lnTotal)*100,2)
>>                              else
>>                                   .MksVolRef=0
>>                              endif
>>                              lcFieldsAdd='MksVolRef, RankVolRef'
>>                         endcase
>>                    endif
>>                    if left(.lender,4)='MISC' or .lender='SELLER'
>>** Nothing
>>                    else
>>                         lnRank=m.lnRank+1
>>                         store m.lnRank to ('loTemp.Rank'+iif(mod(m.i,2)=1,'Num','Vol')+m.lcExt)
>>                    endif
>>                    if .ccode+.townm.lcccTown
>>                         lcccTown= .ccode+.town
>>                         if left(.lender,4)='MISC' or .lender='SELLER'
>>                              lnRank=0
>>                         else
>>                              lnRank=1
>>                              store m.lnRank to ('loTemp.Rank'+iif(mod(i,2)=1,'Num','Vol')+m.lcExt)
>>                         endif
>>                    endif
>>                    lcSearchExpr=m.lcSearchExpr+.lender
>>               endwith
>>               select OutTable
>>               if seek(m.lcSearchExpr,'OutTable','ccttlndr')
>>** We're now on the right record
>>               else
>>                    append blank
>>               endif
>>               gather name loTemp fields ccode, town, Lender, LndrName, county, ;
>>                    city, State, ;
>>                    YtdNumAll, YtdVolAll, PtdNumAll, PtdVolAll, ;
>>                    YtdNumPur, YtdVolPur, PtdNumPur, PtdVolPur, ;
>>                    YtdNumRef, YtdVolRef, PtdNumRef, PtdVolRef, ;
>>                    &lcFieldsAdd
>>          endscan
>>     next
>>
>>It seems to work slow. I believe, I had scatter memvar before and it worked faster, but I'm not sure. So, do you think, it's related with scatter memvar vs. scatter name or do you see some problems in this code, which may cause slowness?
>>
>>Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform