Code: Select all
@SCREEN {Width = 640, Height = 480}
SetFillStyle(#FILLCOLOR)
SetFormStyle(#EDGE,#BLACK,1)
T1={}
T3={}
Dim T2[100001]
Dim T4[100001]
Dim MT[100001]
;Function Ecran
Function Ecran()
For Y=0 To 620 Step 20
Box(0,Y,580,10,$444444,{RoundLevel = 50})
Box(581,Y,640,10,$777777,{RoundLevel = 50})
Next
For Y=10 To 630 Step 20
Box(0,Y,580,10,$777777,{RoundLevel = 50})
Box(581,Y,640,10,$444444,{RoundLevel = 50})
Next
EndFunction
;Function TBoucle
Function TBoucle()
StartTimer(1)
For I=0 To 1000000
Next
Local Temps=GetTimer(1)
TextOut (5,1,"Boucle For (0 à 1 000 000) avec variable Global")
TextOut (586,1,temps)
StartTimer(1)
For Local I=0 To 1000000
Next
Local Temps=GetTimer(1)
TextOut (5,11,"Boucle For (0 à 1 000 000) avec variable Local")
TextOut (586,11,temps)
StartTimer(1)
i=0
While i < 1000000
i = i + 1
Wend
Local Temps=GetTimer(1)
TextOut (5,21,"Boucle While (0 à 1 000 000)")
TextOut (586,21,temps)
i = 0
Repeat
i = i + 1
Until i = 1000000
Local Temps=GetTimer(1)
TextOut (5,31,"Boucle Repeat (0 à 1 000 000)")
TextOut (586,31,temps)
EndFunction
;Function TMemoire
Function TMemoire()
StartTimer(1)
For Local x=0 To 100000
T1[x]=1
Next
Local Temps=GetTimer(1)
TextOut (5,41,"Ecriture dans tableau T1 (Vide) en direct")
TextOut (586,41,temps)
StartTimer(1)
For Local x=0 To 100000
T2[x]=1
Next
Local Temps=GetTimer(1)
TextOut (5,51,"Ecriture dans tableau T2 (Vide) en direct")
TextOut (586,51,temps)
StartTimer(1)
For Local x=0 To 100000
RawSet(T3,x,1)
Next
Local Temps=GetTimer(1)
TextOut (5,61,"Ecriture dans tableau T3 (Vide) par rawset")
TextOut (586,61,temps)
StartTimer(1)
For Local x=0 To 100000
RawSet(T4,x,1)
Next
Local Temps=GetTimer(1)
TextOut (5,71,"Ecriture dans tableau T4 (Vide) par RawSet")
TextOut (586,71,temps)
StartTimer(1)
For Local x=0 To 100000
T1[x]=1
Next
Local Temps=GetTimer(1)
TextOut (5,81,"Ecraser valeur dans tableau T1 (plein) en direct")
TextOut (586,81,temps)
StartTimer(1)
For Local x=0 To 100000
T2[x]=1
Next
Local Temps=GetTimer(1)
TextOut (5,91,"Ecraser valeur dans tableau T2 (plein) en direct")
TextOut (586,91,temps)
StartTimer(1)
For Local x=0 To 100000
RawSet(T3,x,1)
Next
Local Temps=GetTimer(1)
TextOut (5,101,"Ecraser valeur dans tableau T3 (plein) avec Rawset")
TextOut (586,101,temps)
StartTimer(1)
For Local x=0 To 100000
RawSet(T4,x,1)
Next
Local Temps=GetTimer(1)
TextOut (5,111,"Ecraser valeur dans tableau T4 (plein) avec RawSet")
TextOut (586,111,temps)
T1=Nil
T3=Nil
StartTimer(1)
For Local i=0 To 1
T1={}
For Local x=0 To 50000
T1[x]=1
Next
T1=Nil
Next
Local Temps=GetTimer(1)
TextOut (5,121,"(Déclarer tableau T5 mode 1/Ecriture/Libération) *2 en direct")
TextOut (586,121,temps)
T1=Nil
StartTimer(1)
For Local i=0 To 1
Dim T1[50001]
For Local x=0 To 50000
T1[x]=1
Next
T1=Nil
Next
Local Temps=GetTimer(1)
TextOut (5,131,"(Déclarer tableau T6 mode 2/Ecriture/Libération) *2 en direct")
TextOut (586,131,temps)
T1=Nil
StartTimer(1)
For Local i=0 To 1
T1={}
For Local x=0 To 50000
RawSet(T1,x,1)
Next
T1=Nil
Next
Local Temps=GetTimer(1)
TextOut (5,141,"(Déclarer tableau T7 mode Rawset/Ecriture/Libération) *2 en direct")
TextOut (586,141,temps)
T1=Nil
StartTimer(1)
For Local i=0 To 1
Dim T1[50001]
For Local x=0 To 50000
RawSet (T1,x,1)
Next
T1=Nil
Next
Local Temps=GetTimer(1)
TextOut (5,151,"(Déclarer tableau T8 mode Rawset/Ecriture/Libération) *2 en direct")
TextOut (586,151,temps)
StartTimer(1)
For Local x=0 To 100000
Local Val1=T4[X]
Next
Local Temps=GetTimer(1)
TextOut (5,161,"Lecture de valeur d'un tableau en direct")
TextOut (586,161,temps)
StartTimer(1)
For Local x=0 To 100000
Local Val2=RawGet(T4,X)
Next
Local Temps=GetTimer(1)
TextOut (5,171,"Lecture de valeur d'un tableau avec Rawget")
TextOut (586,171,temps)
EndFunction
Function META()
;1
StartTimer(1)
For Local x=0 To 100000
MT[x]=T2[X]+T4[x]
Next
Local Temps=GetTimer(1)
TextOut (5,181,"addition simple de 2 tableaux dans 1 tableau en direct")
TextOut (586,181,temps)
Dim T[100001]
StartTimer(1)
Function T.__add(a,b)
Local result = {}
For Local x=0 To 100000
result [x]=a[x]+b[x]
Next
Return(result)
EndFunction
SetMetaTable(T2, T)
result =T2+T4
Local Temps=GetTimer(1)
TextOut (5,191,"addition direct de 2 tableaux dans 1 tableau (metamethod)")
TextOut (586,191,temps)
;2
StartTimer(1)
For Local x=0 To 100000
MT[x]=T2[X]*T4[x]
Next
Local Temps=GetTimer(1)
TextOut (5,201,"multiplication simple de 2 tableaux dans 1 tableau en direct")
TextOut (586,201,temps)
Dim T[100001]
StartTimer(1)
Function T.__mul(a,b)
Local result = {}
For Local x=0 To 100000
result [x]=a[x]*b[x]
Next
Return(result)
EndFunction
SetMetaTable(T2, T)
result =T2*T4
Local Temps=GetTimer(1)
TextOut (5,211,"mltiplication direct de 2 tableaux dans 1 tableau (metamethod)")
TextOut (586,211,temps)
;3
StartTimer(1)
For Local x=0 To 100000
MT[x]=T2[X]/T4[x]
Next
Local Temps=GetTimer(1)
TextOut (5,221,"Division simple de 2 tableaux dans 1 tableau en direct")
TextOut (586,221,temps)
Dim T[100001]
StartTimer(1)
Function T.__div(a,b)
Local result = {}
For Local x=0 To 100000
result [x]=a[x]/b[x]
Next
Return(result)
EndFunction
SetMetaTable(T2, T)
result =T2/T4
Local Temps=GetTimer(1)
TextOut (5,231,"Division direct de 2 tableaux dans 1 tableau (metamethod)")
TextOut (586,231,temps)
;4
StartTimer(1)
For Local x=0 To 100000
MT[x]=T2[X]-T4[x]
Next
Local Temps=GetTimer(1)
TextOut (5,241,"Soustraction simple de 2 tableaux dans 1 tableau en direct")
TextOut (586,241,temps)
Dim T[100001]
StartTimer(1)
Function T.__sub(a,b)
Local result = {}
For Local x=0 To 100000
result [x]=a[x]-b[x]
Next
Return(result)
EndFunction
SetMetaTable(T2, T)
result =T2-T4
Local Temps=GetTimer(1)
TextOut (5,251,"Soustraction direct de 2 tableaux dans 1 tableau (metamethod)")
TextOut (586,251,temps)
EndFunction
Ecran()
TBoucle()
TMemoire()
META()
Repeat
WaitEvent()
Forever