Tuesday, January 31, 2012

C code optimization benchmark

Can you believe that the code above can be optimized to run 14 times faster on Intel Core i7 CPU and to run 40 times faster on AMD Athlon X2?


#define X_SIZE 60
#define Y_SIZE 30
int matrix[X_SIZE][Y_SIZE];
void initmatrix(void)
{
int x,y;
for (x = 0; x < X_SIZE; ++x){
for (y = 0; y < Y_SIZE; ++y){
matrix[x][y] = -1;
}
}
}
void main()
{
initmatrix();
}

No comments:

Post a Comment