Code: Alles auswählen
OpenConsole()
Declare foo(n.l)
; n should be at least
; 2000000 (on my machine) To get valid result
foo( 2000000)
foo( 4000000)
foo( 8000000)
foo(16000000)
;foo(32000000) ;) got full fridge ?
PrintN ("...FINISHED.")
Input()
CloseConsole()
Procedure foo(n.l)
PrintN( "n=" + Str(n) )
x.l
Dim a.l(n)
NewList b.l()
t0=ElapsedMilliseconds()
For i=0 To n
Next
t0=ElapsedMilliseconds()-t0
PrintN( "empty loop : " + Str( t0 ) + "ms " + Str( t0*100.0/t0 ) + "%" )
;###########################################################################
t1=ElapsedMilliseconds()
For i=0 To n
a(i)=1
Next
t1 = ElapsedMilliseconds() - t1
PrintN( "array - write :" + Str( t1 ) + "ms " + Str( t1*100.0/t0 ) + "%" )
;###########################################################################
t2=ElapsedMilliseconds()
For i=0 To n
x=a(i)
Next
t2 = ElapsedMilliseconds() - t2
PrintN( "array - read :" + Str( t2 ) + "ms " + Str( t2*100.0/t0 ) + "%" )
;###########################################################################
t3=ElapsedMilliseconds()
For i=0 To n
AddElement(b())
Next
t3 = ElapsedMilliseconds() - t3
PrintN( "AddElement() :" + Str( t3 ) + "ms " + Str( t3*100.0/t0 ) + "%" )
;###########################################################################
ResetList(b())
t4=ElapsedMilliseconds()
For i=0 To n
NextElement(b())
Next
t4 = ElapsedMilliseconds() - t4
PrintN( "NextElement() :" + Str( t4 ) + "ms " + Str( t4*100.0/t0 ) + "%" )
;###########################################################################
ResetList(b())
t5=ElapsedMilliseconds()
For i=0 To n
NextElement(b())
b()=1
Next
t5 = ElapsedMilliseconds() - t5
PrintN( "NextElement()/write :" + Str( t5 ) + "ms " + Str( t5*100.0/t0 ) + "%" )
;###########################################################################
FirstElement(b())
t6=ElapsedMilliseconds()
For i=0 To n
DeleteElement(b(),1)
Next
t6 = ElapsedMilliseconds() - t6
PrintN( "DeleteElement() :" + Str( t6 ) + "ms " + Str( t6*100.0/t0 ) + "%" )
;###########################################################################
PrintN("")
PrintN("")
EndProcedure