Original Post
Hi all. Which is faster, leaving "array=0;" inside the loop or removing it and using a memset() after the loop? While I know that I can just write a simple test app and compare the performance, there is more that I would like to know about memset() and similar functions. For example, what's the relationship between the performance of memset and the size of the buffer? Does it perform faster if the buffer is DWORD-aligned? Has a size which is a multiple of 16? Where can I find such information about memset() and other functions.. like malloc(), the new operator... etc. Thanks in advance. P.S: I'm using VC++ 2005 EE, in case it matters.
for( unsigned i=0; i<size; i++ )
{
if( array != 0 )
{
// Some processing here.
array = 0;
}
}
// Alternatively:
memset( array, 0, size*sizeof(int) );