Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Side by side comparison (strings & local data)
Message
De
23/12/2003 11:18:45
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Titre:
Side by side comparison (strings & local data)
Divers
Thread ID:
00861648
Message ID:
00861648
Vues:
78
Hi all

Just did a quick side-by-side comparison with C# and VFP8, the test is aimed at string building from local-data using ADO.Net & Fox's local data-engine, can anyone tell me if I've messed up in away or if there is a quicker way of doing this:

Here's the VFP program:
LOCAL lcXML
lcXML = "<TEST>"

*Start time
SET DECIMALS TO 3

USE C:\DEV\CSHARP\DEMO\DEMOS\DATA\CLIENT IN 0
			
SELECT * FROM Client WHERE UPPER(Cl_Sname) = "LAWRENCE" INTO CURSOR TEST NOFILTER

=AFIELDS(laFields, "Test")

StartTime = SECONDS()

SCAN
	lcXML = lcXML + "<CLIENT>"
	FOR f = 1 TO ALEN(laFields, 1) 
		lcXML = lcXML + "<" + laFields(f, 1) + ">" + ;
			TRANSFORM(EVALUATE("Test." + laFields(f, 1))) +;
			"</" + laFields(f, 1) + ">"
	ENDFOR
	lcXML = lcXML + "</CLIENT>"
ENDSCAN

lcXML = lcXML + "</TEST>"

*Show Time-Taken
?SECONDS() - StartTime
RESULT : Between 0.040 and 0.070 Seconds

And here is the C# Version:
public static void DataPerformance()
	{
	//Use Local FoxDB with lots of data
	OleDbConnection Connection = new OleDbConnection(@"Provider=VFPOLEDB.1;Data Source=c:\dev\csharp\Demo\Demos\Data\Client.DBF") ;
	OleDbDataAdapter Result = new OleDbDataAdapter("SELECT * FROM Client WHERE UPPER(Cl_Sname) = 'LAWRENCE'", Connection) ;
	DataSet Cursor = new DataSet() ;
	Result.Fill(Cursor, "CLIENT") ;
	StringBuilder XML = new StringBuilder() ;
	DataColumn[] Columns = new DataColumn[Cursor.Tables["Client"].Columns.Count];
	Cursor.Tables["Client"].Columns.CopyTo(Columns, 0) ;

	//Start time
	DateTime StartTime = DateTime.Now;

	XML.Append("<Test>") ;
	//Build XML Result
	//Scans through what would be a local-cursor in Fox
	foreach (DataRow Row in Cursor.Tables["CLIENT"].Rows) 
	{
	        XML.Append("<CLIENT>") ;
		for (int c = 0; c < Columns.Length; c++)
			{
				XML.Append("<" + Columns[c].ColumnName + ">" + Row[Columns[c].ColumnName].ToString() + 
					"</" + Columns[c].ColumnName + ">") ;
			}
			XML.Append("</CLIENT>") ;
		}

	XML.Append("</Test>") ;

	//End Time
	DateTime EndTime = DateTime.Now ;

	//End
	Console.WriteLine(StartTime) ;
	Console.WriteLine(EndTime) ;
	Console.WriteLine(EndTime-StartTime) ;
}
RESULT : 0.0100143 Seconds

It may not be a relevent test, I think it is, but let me know. The table in question has 55000 records and the SELECT statment extracts 55 of those. The aim is to demenstrate VFP using a local-cursor and C# using a local ADO.Net DataSet.

Apologies for those who can't read C#.

Thanks
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform