Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Side by side comparison (strings & local data)
Message
From
09/01/2004 07:42:42
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Miscellaneous
Thread ID:
00861648
Message ID:
00865385
Views:
50
>Hi,
>
>I just got in on the tail end of this thread. What does the graph indicate as it relates to C# performance VS VFP8 ?

Hi John,
This was the fastest amongst the ones I tested :
StartTime=Seconds()
lcMyXML=ToXML('testcursor')
? Seconds() - StartTime

lcTemp = Sys(2015)+'.tmp'
Strtofile(m.lcMyXML,m.lcTemp)
Modify Command (m.lcTemp)
Erase (m.lcTemp)

Function ToXML
Lparameters tcCursorName, tcWhere
Local lcChar,lcTemp,lcXML,lcFields,ix,;
  lcFields, lnHandle, lcTempFields
lnSelect = Select()
lcChar=Chr(13)
lcTemp = Sys(2015)+'.tmp'
tcWhere = Iif(Empty(m.tcWhere),'',m.tcWhere)
Select * from (tcCursorName) &tcWhere into cursor _tmpXML

lcTempFields = Sys(2015)+'.tmp'
lnHandle = Fcreate(m.lcTempFields)
Fwrite(m.lnHandle,;
  "f0=IIF(RECNO() = 1,'<TEST>'+CHR(13)+'	<CLIENT>','	<CLIENT>'),")
For ix=1 To Fcount()
  If !Type(Field(m.ix))$'GM'
    Fwrite(m.lnHandle,"f"+Ltrim(Str(ix))+"='		<"+Field(ix)+">'+")
    Fwrite(m.lnHandle,Iif(Type(Field(ix))$'CM',;
      'Trim('+Field(ix)+')+',;
      'Transform('+Field(ix)+')+'))
    Fwrite(m.lnHandle,"'</"+Field(ix)+">',")
  Endif
Endfor
Fwrite(m.lnHandle,"f"+Ltrim(Str(m.ix)))
Fwrite(m.lnHandle,;
  "=Iif(Recno()=Reccount(),'	</CLIENT>'+Chr(13)+'</TEST>','	</CLIENT>')")
Fclose(m.lnHandle)
lcFields = Filetostr(m.lcTempFields)
Erase (m.lcTempFields)

Set Fields Global
Set Fields To &lcFields
Copy To (m.lcTemp) ;
  Type Delimited With "" With Character &lcChar
Use In '_tmpXML'
Set Fields To
Select (m.lnSelect)
lcXML = Filetostr(m.lcTemp)
Erase (m.lcTemp)
Return m.lcXML
C# code :
using System;
using System.Data;
using System.Data.OleDb;
using System.Text;
using System.IO;

namespace VFPvsC
{
	class Class1
	{
		[STAThread]
		static void Main(string[] args)
		{
			DataPerformance2();
		}
		public static void DataPerformance2()
		{
			//Use Local FoxDB with lots of data
			//Start time
			string strCon = 
   "Provider=VFPOLEDB.1;Data Source=d:\\cetin\\ddrive\\temp";
			string strSQL = "SELECT * FROM TestCursor";

			DateTime StartTime = DateTime.Now;
			OleDbConnection cn = new OleDbConnection(strCon) ;
			cn.Open();
			OleDbCommand cmd = new OleDbCommand(strSQL,cn);
			OleDbDataReader rdr = 
                  cmd.ExecuteReader(CommandBehavior.SequentialAccess);

			StringBuilder rowString = new StringBuilder();
			DateTime StartTime2 = DateTime.Now;
			TextWriter wr = 
           new StreamWriter("d:\\cetin\\ddrive\\temp\\output.xml");
			wr.WriteLine("<Test>");
			//Build XML Result
			//Scans through what would be a local-cursor in Fox
			DataTable tbl = rdr.GetSchemaTable();
			rowString.Append("\t<CLIENT>\n");
			for (int cl=0;cl < rdr.FieldCount;cl++)
			{
				rowString.Append("\t\t<" + 
					rdr.GetName(cl) + ">{" + 
					cl.ToString() + "}</" + 
					rdr.GetName(cl) + ">\n") ;
			}
			rowString.Append("\t</CLIENT>");
			string strRow = rowString.ToString();
			object[] rowData = new object[rdr.FieldCount];

			while (rdr.Read())
			{
				rdr.GetValues(rowData);
				wr.WriteLine(strRow,rowData);
			}
			wr.WriteLine("</Test>");
			wr.Close();
			rdr.Close();
			Console.WriteLine(DateTime.Now-StartTime) ;
			Console.WriteLine(DateTime.Now-StartTime2) ;
		}
	}
}
C# timing 17-18secs, VFP just under 7secs.
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform