| 
            Last change
 on this file since 2333 was             2212, checked in by ansari, 23 years ago           | 
        
        
          | 
             
Mise a jour de la documentation SysTools, Reza 15/10/2002 
 
           | 
        
        
          | 
            File size:
            1.7 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 | #include "timing.h"
 | 
|---|
| 33 | 
 | 
|---|
| 34 | static clock_t CPUT0, CPUT;
 | 
|---|
| 35 | static time_t ELT0, ELT;
 | 
|---|
| 36 |  
 | 
|---|
| 37 |  
 | 
|---|
| 38 | /* Nouvelle-Fonction */
 | 
|---|
| 39 | /*!
 | 
|---|
| 40 |    \ingroup SysTools
 | 
|---|
| 41 |    Initializes CPU and elapsed time timer (C function).
 | 
|---|
| 42 |    The values of the CPU and elapsed time can then be printed 
 | 
|---|
| 43 |    using \b PrtTim() 
 | 
|---|
| 44 | */
 | 
|---|
| 45 | void InitTim(void)
 | 
|---|
| 46 | {
 | 
|---|
| 47 | CPUT0 = CPUT = clock();
 | 
|---|
| 48 | ELT0 = ELT = time(NULL);
 | 
|---|
| 49 | return;
 | 
|---|
| 50 | }
 | 
|---|
| 51 |  
 | 
|---|
| 52 | /* Nouvelle-Fonction */
 | 
|---|
| 53 | /*!
 | 
|---|
| 54 |    \ingroup SysTools
 | 
|---|
| 55 |    Prints the values of the CPU and elapsed time, since call to \b InitTim().
 | 
|---|
| 56 | */
 | 
|---|
| 57 | void PrtTim(const char * Comm)
 | 
|---|
| 58 | {
 | 
|---|
| 59 | float tcal,tcalt;
 | 
|---|
| 60 | clock_t cput;
 | 
|---|
| 61 | time_t elt;
 | 
|---|
| 62 | int etm,etmt;
 | 
|---|
| 63 |  
 | 
|---|
| 64 | elt = time(NULL);  cput = clock();
 | 
|---|
| 65 | tcalt = ( (float)(cput) - (float)(CPUT0) ) / (float)(CLOCKS_PER_SEC);
 | 
|---|
| 66 | tcal = ( (float)(cput) - (float)(CPUT) ) / (float)(CLOCKS_PER_SEC);
 | 
|---|
| 67 | etm = elt - ELT;
 | 
|---|
| 68 | etmt = elt - ELT0;
 | 
|---|
| 69 | printf("%s CPUTime: Total= %g  (Partial= %g) Sec. \n",
 | 
|---|
| 70 |        Comm, tcalt, tcal);
 | 
|---|
| 71 | printf("ElapsedTime(hh:mm:ss): Total= %02d:%02d:%02d ",
 | 
|---|
| 72 |        etmt/3600, (etmt%3600)/60, etmt%60);
 | 
|---|
| 73 | printf(" (Partial= %02d:%02d:%02d)\n",
 | 
|---|
| 74 |        etm/3600, (etm%3600)/60, etm%60);
 | 
|---|
| 75 |  
 | 
|---|
| 76 | ELT = elt;
 | 
|---|
| 77 | CPUT = cput;
 | 
|---|
| 78 | return;
 | 
|---|
| 79 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.