Es gibt "spürbare"
Laufzeitunterschiede und SEQUENZ bzw. das erzeugte Array muss früher passen
Ergebnis
![05 05](https://www.clever-excel-forum.de/images/smilies/pack 2/05.gif)
Code:
Option Explicit
Private Declare Function getFrequency Lib "kernel32" _
Alias "QueryPerformanceFrequency" (cyFrequency As Currency) As Long
Private Declare Function getTickCount Lib "kernel32" _
Alias "QueryPerformanceCounter" (cyTickCount As Currency) As Long
Function MicroTimer() As Double
'Returns seconds.
Dim cyTicks1 As Currency
Static cyFrequency As Currency
MicroTimer = 0
' Get frequency.
If cyFrequency = 0 Then getFrequency cyFrequency
' Get ticks.
getTickCount cyTicks1
' Seconds
If cyFrequency Then MicroTimer = cyTicks1 / cyFrequency
End Function
Sub Tester()
Dim tStart As Double
Dim tEnd As Double
Dim i As Long
Dim j As Double
Dim maxVal(1 To 3) As Double
Dim res As Double
maxVal(1) = 10000
maxVal(2) = 100000
maxVal(3) = 1000000
Dim v
For Each v In maxVal
tStart = MicroTimer
res = WorksheetFunction.Sum(WorksheetFunction.Sequence(v))
tEnd = MicroTimer
Debug.Print v, res, tStart, tEnd, Round(tEnd - tStart, 5)
tStart = MicroTimer
res = v * (v + 1) / 2
tEnd = MicroTimer
Debug.Print v, res, tStart, tEnd, Round(tEnd - tStart, 5)
Next v
' Sequence scheitert
v = 10000000
tStart = MicroTimer
res = v * (v + 1) / 2
tEnd = MicroTimer
Debug.Print v, res, tStart, tEnd, Round(tEnd - tStart, 5)
End Sub
PHP-Code:
10000 50005000 385454,7089372 385454,7135735 0,00464
10000 50005000 385454,7166538 385454,7166557 0
100000 5000050000 385454,7181476 385454,728514 0,01037
100000 5000050000 385454,7300566 385454,730058 0
1000000 500000500000 385454,7314826 385454,8267533 0,09527
1000000 500000500000 385454,8283569 385454,8283587 0
10000000 50000005000000 385454,8297901 385454,8297911 0