I faced this problem recently, and I conducted a survey about this issue. The result says Memcpy is much faster than Copy Manually :-) I will take this in my mind in the future and I hope this info will be helpful of you too! ( If you think that this is what everyone knows about, I have to confess that I am ignorant :P ) These programs measure how long it takes during this what-is-called-useless operations. It will let us know the importance of memcpy function actually. I run these programs on my machine, FreeBSD 2.2.8 - Pentium II 400MHz, the memory size is 128MB. The result is:
hm ... the result says that memtest is about 5 times faster than memwaste. It means we should use memcpy function when we copy array variable, and we should not try to copy the array variable one-by-one. hm ... maybe I was too ignorant ... |