This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: TI C/C++ Compiler
Hi,
my customer tested two methods
1.
memset(array, 0, sizeof(array[0][0]) * m * n)
2.
for(j = 0; j < n; j++)
{
for(i = 0; i < m; i++)
{
array[i][j] = 0;
}
}
The second code will occupy more space, but it can run faster than the first code, right? We measured that the second code runs faster, but we are not sure if it's true.
What is the type of one element of the array? If it is a long, float, or double, then I would expect the second version to be faster. memset works one 16-bit word at a time, without regard for the type of the elements in the array. The second version works one element of the array at a time. If that is bigger than a 16-bit word, it will be faster.
Thanks and regards,
-George