| Last change
 on this file since 1670 was             895, checked in by ansari, 26 years ago | 
        
          | 
Documentation de fichiers - Reza 12/4/2000
 | 
        
          | File size:
            1.4 KB | 
      
      
| Rev | Line |  | 
|---|
| [219] | 1 | // This may look like C code, but it is really -*- C++ -*- | 
|---|
|  | 2 | // | 
|---|
| [895] | 3 | // $Id: ctimer.h,v 1.3 2000-04-12 17:49:41 ansari Exp $ | 
|---|
| [219] | 4 | // | 
|---|
|  | 5 |  | 
|---|
|  | 6 |  | 
|---|
|  | 7 | #ifndef CTIMER_SEEN | 
|---|
|  | 8 | #define CTIMER_SEEN | 
|---|
|  | 9 |  | 
|---|
| [895] | 10 | #include "machdefs.h" | 
|---|
| [219] | 11 | #include <sys/types.h> | 
|---|
|  | 12 | #include <time.h> | 
|---|
|  | 13 | #include <iostream.h> | 
|---|
|  | 14 | #include <stdio.h> | 
|---|
| [895] | 15 | #include <string> | 
|---|
| [219] | 16 |  | 
|---|
|  | 17 | // <summary> Permet de chronometrer des fonctions. </summary> | 
|---|
|  | 18 | // La macro TIMEF cree un objet de class Timer qui memorise | 
|---|
|  | 19 | // l'heure de sa creation, et le temps CPU. | 
|---|
|  | 20 |  | 
|---|
|  | 21 | // A la fin du bloc ou de la procedure, l'objet est detruit, | 
|---|
|  | 22 | // et son destructeur affiche le temps ecoule. | 
|---|
|  | 23 |  | 
|---|
|  | 24 | // La macro SPLITTIME lui permet d'afficher des temps partiels. | 
|---|
| [895] | 25 | namespace SOPHYA { | 
|---|
|  | 26 |  | 
|---|
|  | 27 | //! Simple chronometer class | 
|---|
| [241] | 28 | class Timer  { | 
|---|
| [219] | 29 | public: | 
|---|
|  | 30 | // L'objet memorise le temps CPU et l'heure, et le nom donne | 
|---|
|  | 31 | Timer(const char* name=0); | 
|---|
|  | 32 |  | 
|---|
|  | 33 | // Le destructeur appelle split sans parametre. | 
|---|
|  | 34 | virtual ~Timer(); | 
|---|
|  | 35 |  | 
|---|
|  | 36 | // Affiche le temps ecoule total/partiel, avec le nom eventuel. | 
|---|
|  | 37 | // Si pas de parametre affiche le nom donne a la creation. | 
|---|
|  | 38 | void Split(const char* comm=0); | 
|---|
|  | 39 |  | 
|---|
|  | 40 | // Sert a eviter que GNU ne pretende qu'on utilise pas l'objet... | 
|---|
| [895] | 41 | /*! To avoid not used object compiler warnings */ | 
|---|
| [219] | 42 | void Nop() {} | 
|---|
|  | 43 |  | 
|---|
|  | 44 | private: | 
|---|
|  | 45 | clock_t cpu0, cpuSplit; | 
|---|
|  | 46 | time_t  elapse0, elapseSplit; | 
|---|
| [895] | 47 | string timerName; | 
|---|
| [219] | 48 | }; | 
|---|
|  | 49 |  | 
|---|
| [895] | 50 | } // namespace SOPHYA | 
|---|
|  | 51 |  | 
|---|
| [219] | 52 | #define TIMEN(x)  Timer timer(x); timer.Nop(); | 
|---|
|  | 53 | #define TIMEF     Timer timer(__PRETTY_FUNCTION__); timer.Nop(); | 
|---|
|  | 54 | #define SPLITTIME timer.Split(); | 
|---|
|  | 55 |  | 
|---|
|  | 56 | #endif // CTIMER_SEEN | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.