Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Speed testing
#10
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 :

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 Wink Just wanted to test it out Tongue
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)