Bueno, resulta que tengo dos códigos (a simple vista parecen idénticos) pero, cuando ejecuto /usr/bin/time -v desde el terminal de Linux, el terminal se me demora mucho más en calcular el tiempo de ejecución del segundo código que el del primero.
¿Alguien sabe a que se debe?
Código:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 4000
// Matrix
long long int A[N][N],B[N][N],R[N][N];
int main()
{
int x,y,z;
char str[100];
/* Matrix initialization */
for(y=0;y<N;y++)
for(x=0;x<N;x++)
{
A[y][x]=x;
B[y][x]=y;
R[y][x]=0;
}
/* Matrix multiplication */
for(y=0;y<N;y++)
for(z=0;z<N;z++)
for(x=0;x<N;x++)
{
R[y][x]+= A[y][z] * B[z][x];
}
exit(0);
}
#include <string.h>
#include <stdlib.h>
#define N 4000
// Matrix
long long int A[N][N],B[N][N],R[N][N];
int main()
{
int x,y,z;
char str[100];
/* Matrix initialization */
for(y=0;y<N;y++)
for(x=0;x<N;x++)
{
A[y][x]=x;
B[y][x]=y;
R[y][x]=0;
}
/* Matrix multiplication */
for(y=0;y<N;y++)
for(z=0;z<N;z++)
for(x=0;x<N;x++)
{
R[y][x]+= A[y][z] * B[z][x];
}
exit(0);
}
Código:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 4000
// Matrix
long long int A[N][N],B[N][N],R[N][N];
int main()
{
int x,y,z;
char str[100];
/* Matrix inicialization */
for(y=0;y<N;y++)
for(x=0;x<N;x++)
{
A[y][x]=x;
B[y][x]=y;
R[y][x]=0;
}
/* Matrix multiplication */
for(x=0;x<N;x++)
for(z=0;z<N;z++)
for(y=0;y<N;y++)
{
R[y][x]+= A[y][z] * B[z][x];
}
exit(0);
}
#include <string.h>
#include <stdlib.h>
#define N 4000
// Matrix
long long int A[N][N],B[N][N],R[N][N];
int main()
{
int x,y,z;
char str[100];
/* Matrix inicialization */
for(y=0;y<N;y++)
for(x=0;x<N;x++)
{
A[y][x]=x;
B[y][x]=y;
R[y][x]=0;
}
/* Matrix multiplication */
for(x=0;x<N;x++)
for(z=0;z<N;z++)
for(y=0;y<N;y++)
{
R[y][x]+= A[y][z] * B[z][x];
}
exit(0);
}
Gracias