please see this code:
Code: Select all
cBuffer := DateTime.Now:ToString()
foreach oTag as PlanTag in _oPlanTage
cBuffer := cBuffer + oTag:DebugString( 1 )
foreach oPosition as PlanPosition in _oPlanPositionen
cBuffer := cBuffer + oPosition:DebugString( 1 )
next
next
cBuffer := cBuffer + DateTime.Now:ToString()
The code takes a lot of time (5 minutes 36 seconds) and uses an entire processor core.
A simple optimization makes it behave better:
Code: Select all
cBuffer := DateTime.Now:ToString()
foreach oTag as PlanTag in _oPlanTage
cBuffer := cBuffer + oTag:DebugString( 1 )
cPosition := ""
foreach oPosition as PlanPosition in _oPlanPositionen
cPosition := cPosition + oPosition:DebugString( 1 )
next
cBuffer := cBuffer + cPosition
next
cBuffer := cBuffer + DateTime.Now:ToString()
This reduces the needed time to about 4 seconds!!!
But the use of the StringBuilder class makes the code again perform faster:
Code: Select all
oSB := StringBuilder{}
oSB:AppendLine( DateTime.Now:ToString() )
foreach oTag as PlanTag in _oPlanTage
oSB:Append( oTag:DebugString( 1 ) )
foreach oPosition as PlanPosition in _oPlanPositionen
oSB:Append( oPosition:DebugString( 1 ) )
next
next
oSB:AppendLine( DateTime.Now:ToString() )
cBuffer := oSB:ToString()
Wolfgang
P.S. in VO you can see similar differences, but there is no StringBuilder class available.