Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Side by side comparison (strings & local data)
Message
De
24/12/2003 07:11:44
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Divers
Thread ID:
00861648
Message ID:
00861886
Vues:
31
>
>In addition, ALEN(laFields, 1) can be taken out of SCAN loop and assigned the variable just once.

Hi Nick,
Yes and yet many more - ie: might even try directly constructing the sql that'd give the result already transformed and tagged:) I used Dragan's approach in one of my needs and it really speeds up the things more.
You VFP guys never confident with speed :)
OK I did another version and didn't seek for further optimization :
StartTime=Seconds()
lcMyXML=ToXML('testcursor')
*Show Time-Taken
?'Before Test Tag added',Seconds() - StartTime

*Add test tag
lcTemp = Sys(2015)+'.tmp'
StrToFile('<TEST>'+Chr(13),m.lcTemp)
Strtofile(m.lcMyXML,m.lcTemp,.t.)
StrToFile('</TEST>',m.lcTemp,.t.)
?'After Test Tag added',Seconds() - StartTime

* Check what really we've generated
Modify Command (m.lcTemp)
Erase (m.lcTemp)

Function ToXML
Lparameters tcCursorName, tcWhere
Local lcChar,lcTemp,lcXML,lcFields,ix
lcChar=Chr(13)
lcTemp = Sys(2015)+'.tmp'
tcWhere = Iif(Empty(m.tcWhere),'',m.tcWhere)
Select * from (tcCursorname) &tcWhere into cursor _tmpXML
Local lcFields
Set Textmerge Delimiters To "%%","%%"
Set Textmerge To Memvar m.lcFields Noshow
Set Textmerge On
\\f0='<CLIENT>',
For ix=1 To Fcount()
  If !Type(Field(ix))$'GM'
		\\f%%ix%%='&lt;%%Field(ix)%%>'+
		\\%%Iif(Type(Field(ix))$'CM','Trim(','Transform(')%%%%Field(ix)%%)
		\\+'</%%Field(ix)%%>',
  Endif
Endfor
\\f%%ix%%='</CLIENT>'
Set Textmerge To
Set Textmerge Off
Set Fields Global
Set Fields To &lcFields
Copy To (m.lcTemp) Type Delimited With "" With Character &lcChar
USE in '_tmpXML'
Set Fields to
lcXML = Filetostr(m.lcTemp)
Erase (m.lcTemp)
Return m.lcXML
And timings on my box (Athlon 650Mhz, 192Mb RAM) :
Final XMLed file size for this test was 22Mb

VFP did that in 8.01 - 8.20 seconds w/o test tag and 9.5 - 9.6 seconds with test tag added. There I did a read all and write again as you noticed.
In the meantime I also tried not doing a select but a use again + for clause in 'copy to' and it further decreased to time around 7.0-7.4 seconds
I still feel I have the power to make it faster than that but seemed enough to me for this test:)

Now timings for C# with the same 'TestCursor' (and I tried to make the environment best for C# as far as I know - what I didn't do is trying to optimize the code Kevin supplied, IOW C# test code is his code except only the path to table) :
C# did it in 69 seconds if run directly from development IDE w/o debugging. Well actually it was its start-end timing, my wristwatch showed it took more than 100 secs. to see the result.
I compiled to .exe with csc and that version took 44 seconds, after I NGen'd it was down only 1 sec and took 43 seconds.
PS: I really don't know why yesterday it took 132 secs for C# to complete, maybe it had less free memory when I tried yesterday or I might have tried with debugging.
I don't say so VFP is exactly better with these tests, but at least it showed with in the aspects of such a test it's much faster + its IDE capability is much better (I hate development time penalties of .NET if you've to try and go into edit even to modify a single line of code - VFP's interactivity alone is a feature I love, hope there is some in .NET too which I'm not yet aware of).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform