Creo que la función gettimeofday tenía una precisión de microsegundos (0.001 milisegundos)
Cita:
// include necesario
#include <sys/time.h>
.......
// Aqui empieza lo bueno
struct timeval tini, tfin;
long ltiempo;
float ftiempo;
// Tomas el tiempo antes de hacer lo que sea
gettimeofday(&tini, NULL);
// Aqui llamarias a la funcion que haga lo que tengas que hacer
// Aqui tomas el tiempo de nuevo
gettimeofday(&tfin, NULL);
ltiempo= (tfin.tv_sec - tini.tv_sec)*1000000 + tfin.tv_usec - tini.tv_usec;
ftiempo= ltiempo/1000.0;
printf("Se tardo: %g milisegundos\n", ftiempo);
// o ltiempo si quieres mostrar microsegundos
|
Saludos
Última edición por ElZazu; 09/02/2006 a las 22:11.
|