question sur un programme
Bonjour, j'ai télécharger une fonction qui chronomètre mon programme (http://c.developpez.com/sources/?pag...DATE_get_clock). Mais j'ai l'impression que si __linux ou _WIN32 sont définies alros on exécute le même code. Pourquoi, le code n'a-t-il pas été simplifié ainsi :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
double GetClock ( void )
{
double d=-1.0 ;
#if definded _WIN32 || defined __linux
struct timeval tval ;
struct timezone *tz=(struct timezone *)NULL ;
timerclear(&tval);
if ( gettimeofday(&tval, tz) )
{
#ifdef VERBOSE
fprintf (stderr, "\nCLOCK ERROR !!!\n");
#endif
}
else
{
d = ((double)(tval.tv_usec)/1000000.0) ;
d = (double) tval.tv_sec + d ;
}
#else
struct timespec cur_time, res ;
if (clock_gettime(CLOCK_REALTIME, &cur_time))
{
#ifdef VERBOSE
fprintf (stderr, "\nCLOCK ERROR !!!\n");
#endif
}
else
{
d = ((double)(cur_time.tv_nsec)/1000.0) / 1000000.0 ;
d = (double) cur_time.tv_sec + d ;
}
#endif
return d ;
} |