|
发表于 2010-6-20 11:17:00
|
显示全部楼层
Re:ZeroMemory 和memset的速度谁快?
memset及memcpy的速度受很多因素影响,和不同的平台、库和编译器的实现方式都有关系
int* d;
int* s;
//Ignore some code
假设有上面两块Buffer
for(int i = 0; i < BUFSIZE; i++) {
*d++ = *s++;
};
例如某些平台上面这段代码要比下面的代码效率高
memcpy(d, s, BUFSIZE * sizeof(int));
|
|