GCCollect timings.

BlitzMax Forums/BlitzMax Programming/GCCollect timings.

I'm not entirely sure what I am showing here but I got the following results with this code :
Normal GC (comment GCSetMode and GCCollects)
447 633 12088
No GC (uncomment GCSetmode 2, comment GCCollects)
666 1528 6413162
Manual GC (uncomment GCSetmode 2 and GCCollects)
665 235 3212106
Normal GC plus manual collects (comment GCSetmode, Uncomment gccollect)
336 264 12024
I don't think the actual test run is important other than to check timings.
SuperStrict
Const num_objects:Int=100000
Type ttest 
	Field x:Int=999
End Type
Local mylist:tlist=CreateList()
Local mytemp:ttest
'GCSetMode 2
Local time1:Int = MilliSecs()
For Local x:Int = 0 To num_objects - 1
	mytemp:ttest = New ttest
	ListAddLast mylist,mytemp
Next
ClearList(mylist)
Local time2:Int=MilliSecs()
GCCollect()
Local time3:Int=MilliSecs()
For Local x:Int = 0 To num_objects - 1
	mytemp:ttest = New ttest
	ListAddLast mylist,mytemp
Next
ClearList(mylist)
Local time4:Int = MilliSecs()
Print (time2-time1) + " " + (time4-time3)
GCCollect()
Print GCMemAlloced()
	


The results suggest
- No GC is terrible.... duh!!!
- GC is OK
- Manual GC is better
- Auto plus user decided GCollects() is best.
.
I *did* think of some complicated system of manual GC where I turned off auto-GC and checked some available mem, last run algo and scheduled GCCollect during a quiet time (between levels, player dies etc).
However, for now, what do you make of the results?<edit> P.S. I realise the GCCollect is outside the timing code but it's to show what happens if you decide where to run it.
<edit2> Interestingly, putting the gccollect in the second time-set makes a shorter total-time than auto-GC than putting it in the first. I guess it will do additional things to Auto-GC in the first test.
<edit3> I think what I am saying is, much like we put a flushmem into a heavy function, it might be worth scheduling your own GCCollects in strategic places... or do you all do that already?