| Last change
 on this file since 575 was             219, checked in by ansari, 27 years ago | 
        
          | 
Creation module DPC/SysTools Reza 09/04/99
 | 
        
          | File size:
            1.4 KB | 
      
      
| Line |  | 
|---|
| 1 | /*    Fonction d'impression de temps de calcul et de temps passe  */ | 
|---|
| 2 | /*                               R.Ansari    Juin 93              */ | 
|---|
| 3 |  | 
|---|
| 4 | /* | 
|---|
| 5 | ++ | 
|---|
| 6 | Module        Temps CPU, passé (C) | 
|---|
| 7 | Lib   LibsUtil | 
|---|
| 8 | include       timing.h | 
|---|
| 9 |  | 
|---|
| 10 | Fonctions permettant d'imprimer le temps CPU consommé et le temps | 
|---|
| 11 | passé. | 
|---|
| 12 | -- | 
|---|
| 13 | */ | 
|---|
| 14 |  | 
|---|
| 15 | /* | 
|---|
| 16 | ++ | 
|---|
| 17 | void InitTim() | 
|---|
| 18 | Initialisation des chronomètres | 
|---|
| 19 | void PrtTim(char *comm) | 
|---|
| 20 | Imprime le temps CPU, et le temps passé depuis | 
|---|
| 21 | le dernier appel à "PrtTim()" avec le commentaire | 
|---|
| 22 | "comm". Imprime aussi le cumul du temps CPU et du | 
|---|
| 23 | temps passé depuis l'appel à "InitTim()". | 
|---|
| 24 | -- | 
|---|
| 25 | */ | 
|---|
| 26 |  | 
|---|
| 27 | #include <stdlib.h> | 
|---|
| 28 | #include <stdio.h> | 
|---|
| 29 | #include <string.h> | 
|---|
| 30 | #include <time.h> | 
|---|
| 31 |  | 
|---|
| 32 | clock_t CPUT0, CPUT; | 
|---|
| 33 | time_t ELT0, ELT; | 
|---|
| 34 |  | 
|---|
| 35 | void InitTim(void); | 
|---|
| 36 | void PrtTim(char *Comm); | 
|---|
| 37 |  | 
|---|
| 38 | /* Nouvelle-Fonction */ | 
|---|
| 39 | void InitTim(void) | 
|---|
| 40 | { | 
|---|
| 41 | CPUT0 = CPUT = clock(); | 
|---|
| 42 | ELT0 = ELT = time(NULL); | 
|---|
| 43 | return; | 
|---|
| 44 | } | 
|---|
| 45 |  | 
|---|
| 46 | /* Nouvelle-Fonction */ | 
|---|
| 47 | void PrtTim(char *Comm) | 
|---|
| 48 | { | 
|---|
| 49 | float tcal,tcalt; | 
|---|
| 50 | clock_t cput; | 
|---|
| 51 | time_t elt; | 
|---|
| 52 | int etm,etmt; | 
|---|
| 53 |  | 
|---|
| 54 | elt = time(NULL);  cput = clock(); | 
|---|
| 55 | tcalt = ( (float)(cput) - (float)(CPUT0) ) / (float)(CLOCKS_PER_SEC); | 
|---|
| 56 | tcal = ( (float)(cput) - (float)(CPUT) ) / (float)(CLOCKS_PER_SEC); | 
|---|
| 57 | etm = elt - ELT; | 
|---|
| 58 | etmt = elt - ELT0; | 
|---|
| 59 | printf("%s CPUTime: Total= %g  (Partial= %g) Sec. \n", | 
|---|
| 60 | Comm, tcalt, tcal); | 
|---|
| 61 | printf("ElapsedTime(hh:mm:ss): Total= %02d:%02d:%02d ", | 
|---|
| 62 | etmt/3600, (etmt%3600)/60, etmt%60); | 
|---|
| 63 | printf(" (Partial= %02d:%02d:%02d)\n", | 
|---|
| 64 | etm/3600, (etm%3600)/60, etm%60); | 
|---|
| 65 |  | 
|---|
| 66 | ELT = elt; | 
|---|
| 67 | CPUT = cput; | 
|---|
| 68 | return; | 
|---|
| 69 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.