1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
Sub TestPerf()
Const clTests As Long = 1000000
Const cMaxJ As Byte = 240
Dim i As Long
Dim r As Byte, n1 As Byte, n2 As Byte
Dim t1 As Single, t2 As Single, tb As Single
Randomize
Debug.Print "Test performance sur " & FormatNumber(clTests, 0) & " essais..."
'Blanc
tb = Timer()
For i = 1 To clTests
n1 = CByte(Int(Rnd() * cMaxJ) + 1)
n2 = CByte(Int(Rnd() * 7) + 1)
Next i
tb = Timer() - tb
Debug.Print "Temps du blanc : " & tb
Randomize
'Algo 1
t1 = Timer()
For i = 1 To clTests
n1 = CByte(Int(Rnd() * cMaxJ) + 1)
n2 = CByte(Int(Rnd() * 7) + 1)
r = JoursOuvrables(n1, n2)
Next i
t1 = Timer() - t1 - tb
Debug.Print "Temps algo n°1 corrigé : " & t1
Randomize
'Algo 2
t2 = Timer()
For i = 1 To clTests
n1 = CByte(Int(Rnd() * cMaxJ) + 1)
n2 = CByte(Int(Rnd() * 7) + 1)
r = JoursOuvrables3(n1, n2)
Next i
t2 = Timer() - t2 - tb
Debug.Print "Temps algo n°2 corrigé : " & t2
Debug.Print "L'algo n°" & IIf(t2 < t1, "2", "1") & " est " & _
FormatNumber(IIf(t2 < t1, t1 / t2, t2 / t1)) & " plus rapide que l'algo n°" & _
IIf(t1 < t2, "2", "1")
End Sub |
Partager