/* Fonction d'impression de temps de calcul et de temps passe */ /* R.Ansari Juin 93 */ #include #include #include #include clock_t CPUT0, CPUT; time_t ELT0, ELT; void InitTim(void); void PrtTim(const char *Comm); /* Nouvelle-Fonction */ void InitTim(void) { CPUT0 = CPUT = clock(); ELT0 = ELT = time(NULL); return; } /* Nouvelle-Fonction */ void PrtTim(const char *Comm) { float tcal,tcalt; clock_t cput; time_t elt; int etm,etmt; elt = time(NULL); cput = clock(); tcalt = ( (float)(cput) - (float)(CPUT0) ) / (float)(CLOCKS_PER_SEC); tcal = ( (float)(cput) - (float)(CPUT) ) / (float)(CLOCKS_PER_SEC); etm = elt - ELT; etmt = elt - ELT0; printf("%s CPUTime: Total= %g (Partial= %g) Sec. \n", Comm, tcalt, tcal); printf("ElapsedTime(hh:mm:ss): Total= %02d:%02d:%02d ", etmt/3600, (etmt%3600)/60, etmt%60); printf(" (Partial= %02d:%02d:%02d)\n", etm/3600, (etm%3600)/60, etm%60); ELT = elt; CPUT = cput; return; }