
Seems to be about 10x faster than regular concatenation.
Code: Select all
EnableExplicit
DisableDebugger
OpenConsole("Testing facility")
Define.i Time
Define.i Counter, Count
Count = 500000
Define A$
Define B$, C$, D
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; case A, regular
Time = ElapsedMilliseconds()
For Counter = 1 To Count
A$ + "a"
Next Counter
Time = ElapsedMilliseconds() - Time
PrintN("Cycle 1: " + Str(Time) + "ms")
;---------------------------------------------;
; case B. C$ variable used as buffer which is added to B$ and flushed with some interval
Time = ElapsedMilliseconds()
For Counter = 1 To Count
C$ + "a" ; instead of adding directly to B$
D + 1
If D % 50000 = 0 ; clear every N chars
B$ + C$
C$ = ""
EndIf
Next Counter
Time = ElapsedMilliseconds() - Time
PrintN("Cycle 2: " + Str(Time) + "ms")
; print here len of A and B to check if all ok
PrintN(Str(Len(A$)))
PrintN(Str(Len(B$)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Input()