09-10-2008, 01:41 AM
I was curious as to whether ZeroMemory was faster then erasing an array and redimming it for temporary arrays. Here is the code i used :
And here were the results :
Thus, ZeroMemory is much faster
Just wanted to test it out
Code:
Dim I As Long, Counter As Byte
Dim timer As Long
Dim bytA() As Byte
ReDim bytA(1000) As Byte
For Counter = 1 To 5
timer = GetTickCount
For I = 1 To 1000000
ZeroMemory bytA(0), 1001
Next I
Debug.Print "Zero Memory - " & GetTickCount - timer
timer = GetTickCount
For I = 1 To 1000000
Erase bytA
ReDim bytA(1000) As Byte
Next I
Debug.Print "Erasing - " & GetTickCount - timer
Next Counter
And here were the results :
Code:
Zero Memory - 203
Erasing - 577
Zero Memory - 219
Erasing - 561
Zero Memory - 203
Erasing - 562
Zero Memory - 203
Erasing - 562
Zero Memory - 202
Erasing - 578
Thus, ZeroMemory is much faster

