Results 1 to 21 of 21

Thread: Speed Test - Loop vs CopyMemory

Hybrid View

  1. #1
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Speed Test - Loop vs CopyMemory

    You still have to loop to copy memory, don't you? Or are you going to read a large block at once to copy 4K of info? That may be the problem.

  2. #2
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Speed Test - Loop vs CopyMemory

    Copymemory is much faster.
    It is more difficult to move the array up than down

    VB Code:
    1. 'move array up
    2.    '1st to temp array
    3.    CopyMemory temp(LBound(temp)), arr(LBound(arr)), (UBound(arr) - 1) * Len(arr(UBound(arr)))
    4.    'back to our array
    5.    CopyMemory arr(LBound(arr) + 1), temp(LBound(temp)), (UBound(arr) - 1) * Len(arr(UBound(arr)))
    6.    
    7.    'move array down
    8.    CopyMemory arr(LBound(arr)), arr(LBound(arr) + 1), (UBound(arr) - 1) * Len(arr(UBound(arr)))

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: Speed Test - Loop vs CopyMemory

    moeur

    Thanks for taking your time to respond and pointing out my error.

    I'm still not convinced CopyMemory is faster. From my testing so far,
    like most things it depends. If you have multiple arrays then the loop
    may be faster than multiple calls to CopyMemory.

    From the tests I've run so far, the Loop = CopyMemory till around 12000 elements (at least will 5 arrays), then CopyMemory wins.

    Attached is a revised example.

    David.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width