Application = XBPerfXS
IDEVersion = 2.19
GalleryName = 
GalleryPage = 
GalleryDefaultName = 
Target = 0
Platform = x86
Language = XSharp
Runtime = CLR4
Dialect = VO
Folder = C:\XSharp\XIDE\Projects\VO_Applications\Applications\XBPerfXS\
PrgSubFolder = \
ResourcesSubFolder = \
Description = 
NameSpace = 
Assembly = XBPerfXS
Extension = 
ApplicationIcon = 
OutputFolder = 
Frameworks = 1
GUID = 7A6883D8-9CE5-4223-A0CD-C1E8B26D80B0
IncludeInProjectBuild = 1
IncludeInProjectSearch = 1
IncludeInProjectExport = 1
IncludePath = 
StdDefsFile = 
AppToRun = 
SignAssembly = 0
KeyFile = 

[ExportOptions]
ExportResources = 1
ExportImages = 1
[XBPerfXS FileGroups]
[XBPerfXS Files]
File = %AppPath%\XBPerf.prg
FileGUID = ACF2F512-09D5-44D1-BC43-AA22A5ECFC90
FileType = Code
CopyToBin = 0
[XBPerfXS References]
ReferenceGAC = CLR4,System,1,0,4.0.0.0
ReferenceGAC = CLR4,XSharp.Core,1,0,2.6.0.0
ReferenceGAC = CLR4,XSharp.RT,1,0,2.6.0.0
ReferenceGAC = CLR4,XSharp.VO,1,0,2.6.0.0
ReferenceGAC = CLR4,VOConsoleClasses,1,0,2.6.0.0
ReferenceGAC = CLR4,VOConsoleClasses,1,0,2.6.0.0
ReferenceGAC = CLR4,VOWin32APILibrary,1,0,2.6.0.0
[XBPerfXS Resources]
[XBPerfXS Native Resources]
[XBPerfXS License files]
[XBPerfXS General Options]
Switches=/nowarn:9032,9043,165,649,9025,9026,9076,9020,9021
ZeroArrays=0
CaseSensitive=0
ImplicitNamespace=1
VO1=1
VO2=1
VO3=1
VO4=1
VO5=1
VO6=1
VO7=1
VO8=1
VO9=1
VO10=1
VO11=1
VO12=0
VO13=1
VO14=1
VO16=1
VO17=0
FOX1=0
FOX2=0
XPP1=0
LateBound=1
Unsafe=1
Undeclared=0
EnforceSelf=1
EnforceOverride=0
UseNativeVersion=0
MemVar=0
IgnoreStdDefs=0
Ovf=1
FOvf=1
ResponseOnly=0
[XBPerfXS Configurations]
AppConfig = Debug,11111111-1111-1111-1111-111111111111
  Switches=
  SwitchesCF=
  CommandLine=
  CommandLineCF=
  Debug=1
  DebugInit=1
  DefineDebug=1
  DefineTrace=0
  SyntaxOnly=0
  WarningsErrors=0
  ForceConsole=0
  ForceX86=0
  Optimize=0
AppConfig = Release,22222222-2222-2222-2222-222222222222
  Switches=
  SwitchesCF=
  CommandLine=
  CommandLineCF=
  Debug=0
  DebugInit=0
  DefineDebug=0
  DefineTrace=0
  SyntaxOnly=0
  WarningsErrors=0
  ForceConsole=0
  ForceX86=0
  Optimize=0
ENDApplication = XBPerfXS

[FileContents]
%#IDE#%File=TEXT,ACF2F512-09D5-44D1-BC43-AA22A5ECFC90
function Start() as void
// (c) Wolfgang Riedmann 1994-2001
// http://www.riedmann.it
// measure the XBase performance
	local hResult 		as ptr
	local cDatabase     as string
	local nArea         as dword
	local nStart        as dword
	local nStartTotal   as dword
	local cNewLine		as string
	local aStruct       as array
	local nMax			as dword
	local nI			as dword
	local cBuffer     	as string
	local cResult		as string
	local nResult		as int
	local oConsole		as Console

	// prepare log file and database
	oConsole		:= Console{ false }
	oConsole:WriteLine( "XBPerf - measure the xBase performance. (c) Wolfgang Riedmann 1994-2010" )
	nMax			:= 50000
	cBuffer			:= ""
	for nI := 1 to 100
		cBuffer			+= chr( nI + 32 )
	next
	cNewLine		:= chr( 13 ) + chr( 10 )
	hResult			:= FOpen( "XBPerf.log", 2 )		// FO_READWRITE
	if FError() != 0
		hResult			:= FCreate( "XBPerf.log" )
	else
		FSeek( hResult, 0, 2 )		// FS_END
	endif
	FErase( "XBPERF.DBF" )
	FErase( "XBPERF.CDX" )
	aStruct			:= {}
	AAdd( aStruct, { "FIELD1", "C", 20, 0 } )
	AAdd( aStruct, { "FIELD2", "N", 10, 0 } )
	AAdd( aStruct, { "FIELD3", "C", 100, 0 } )
	DBCreate( "XBPerf.DBF", aStruct, "DBFCDX", .t., "XBPERF" )
	if Select( "XBPERF" ) > 0
		XBPERF->( DBCloseArea() )
	endif
	DBUseArea( .t., "DBFCDX", "XBPerf.DBF", "XBPERF", .t., .f. )

	nStart			:= Seconds()
	nStartTotal		:= nStart
	cResult			:= "Start " + DToC( Today() ) + " " + Time()
	FWrite( hResult, cNewLine + cResult + cNewLine )
	oConsole:WriteLine( cResult )

	// test the append performance without index
	for nI := 1 to nMax
		XBPERF->( DBAppend() )
		XBPERF->( FieldPut( 1, Str( nI, 10 ) + Str( nMax - nI, 10 ) ) )
		XBPERF->( FieldPut( 2, nI ) )
		XBPERF->( FieldPut( 3, cBuffer ) )
		XBPERF->( DBCommit() )
	next
	cResult			:= "Append of " + AllTrim( Str( nMax, 10 ) ) + " records:" + Str( Seconds() - nStart, 10, 2 ) + " seconds"
	FWrite( hResult, cResult + cNewLine )
	oConsole:WriteLine( cResult )
	XBPERF->( DBCloseArea() )
	DBUseArea( .t., "DBFCDX", "XBPerf.DBF", "XBPERF", .f., .f. )		// open exclusive

	// reindex performance
	nStart			:= Seconds()
	XBPERF->( OrdCreate( "XBPerf.CDX", "ORDER1", "FIELD1", {|| _FIELD->FIELD1 } ) )
	XBPERF->( OrdCreate( "XBPerf.CDX", "ORDER2", "STR(FIELD2,10)", {|| Str(_FIELD->FIELD2, 10 ) } ) )
	XBPERF->( OrdCreate( "XBPerf.CDX", "ORDER3", "FIELD3+STR(RECNO(),10)", {|| _FIELD->FIELD3 + Str( Recno(), 10 ) } ) )
	cResult			:= "Reindex of " + AllTrim( Str( nMax, 10 ) ) + " records:" + Str( Seconds() - nStart, 10, 2 ) + " seconds"
	FWrite( hResult, cResult + cNewLine )
	oConsole:WriteLine( cResult )
	XBPERF->( DBCloseArea() )
	DBUseArea( .t., "DBFCDX", "XBPerf.DBF", "XBPERF", .t., .f. )		// open shared
//	XBPERF->( OrdListAdd( "XBPERF.CDX" ) )

	// seek performance
	XBPERF->( OrdSetFocus( "ORDER2" ) )
	nStart			:= Seconds()
	for nI := 1 to nMax
		XBPERF->( DBSeek( Str( ( Seconds() * nMax * nI ) % nMax, 10, 0 ), .f. ) )
		cResult			:= XBPERF->FIELD3
	next
	cResult			:= "Seek of " + AllTrim( Str( nMax, 10 ) ) + " records:" + Str( Seconds() - nStart, 10, 2 ) + " seconds"
	FWrite( hResult, cResult + cNewLine )
	oConsole:WriteLine( cResult )
	XBPERF->( OrdSetFocus( "ORDER2" ) )
	XBPERF->( DBGoTop() )

	// update with change of key value
	nStart			:= Seconds()
	while ! XBPERF->( EOF() )
		XBPERF->( RLock() )
		XBPERF->( FieldPut( 1, Str( nMax - Recno(), 10 ) + Str( Recno(), 10 ) ) )
		XBPERF->( DBUnlock() )
		XBPERF->( DBSkip( 1 ) )
	end
	cResult			:= "Update of " + AllTrim( Str( nMax, 10 ) ) + " records:" + Str( Seconds() - nStart, 10, 2 ) + " seconds"
	FWrite( hResult, cResult + cNewLine )
	oConsole:WriteLine( cResult )
	XBPERF->( OrdSetFocus( 0 ) )
	XBPERF->( DBGoTop() )

	// sequential read in natural order
	nStart			:= Seconds()
	while ! XBPERF->( EOF() )
		nResult				:= XBPERF->FIELD2
		XBPERF->( DBSkip( 1 ) )
	end
	cResult			:= "Sequential read of " + AllTrim( Str( nMax, 10 ) ) + " records:" + Str( Seconds() - nStart, 10, 2 ) + " seconds"
	FWrite( hResult, cResult + cNewLine )
	oConsole:WriteLine( cResult )

	XBPERF->( OrdSetFocus( "ORDER2" ) )
	XBPERF->( DBGoTop() )

	// sequential read in index order
	nStart			:= Seconds()
	while ! XBPERF->( EOF() )
		nResult				:= XBPERF->FIELD2
		XBPERF->( DBSkip( 1 ) )
	end
	cResult			:= "Index read of " + AllTrim( Str( nMax, 10 ) ) + " records:" + Str( Seconds() - nStart, 10, 2 ) + " seconds"
	FWrite( hResult, cResult + cNewLine )
	oConsole:WriteLine( cResult )

	cResult			:= cNewLine + "Total time used for " + AllTrim( Str( nMax, 10 ) ) + " records:" + ;
				Str( Seconds() - nStartTotal, 10, 2 ) + " seconds"
	FWrite( hResult, cResult + cNewLine )
	oConsole:WriteLine( cResult )

	XBPERF->( DBCloseArea() )
	FClose( hResult )

	return nil

