VBGamer |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RE: Is CopyMemory faster than ... Adam Hoult (4 replies, 0 views) (2000-Jun-24) ![]() Well you couldn't do that, since the number 20 is not an actual area of memory =) If it did try and copy it, i would assume it would attempt to copy the area of memory with the long pointer 20 =)
But if we were talking about copying a variable containing the number 20 (an integer for example) then no, it's not quicker because we have the added overhead of calling the function, and pointer conversion etc
Couple of benchmarks for you
1 million copys using var1=var2 is 170ms
1 million copys using copymemory is 400ms (since we have to call CopyMemory 1 million times) =)
Copymemory is designed to copy areas of memory. Just as an example, to copy a 2,000,000 element byte array without using CopyMemory (i.e looping through the array) took just under 1 second, wheras copy memory took 2ms
Ok so lets try a 20,000,000 element byte array =)
The standard way took 9 seconds, copymemory took 130ms to copy almost 20 megs of data. Obviously it's benefits get larger, the more data is being shifted.
Adam
Sysop
![]()
|