|
Last change
on this file since 2673 was 2322, checked in by cmv, 23 years ago |
- passage xxstream.h en xxstream
- compile avec gcc_3.2, gcc_2.96 et cxx
En 3.2 le seek from ::end semble marcher (voir Eval/COS/pbseekios.cc)
rz+cmv 11/2/2003
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | // This may look like C code, but it is really -*- C++ -*-
|
|---|
| 2 | //
|
|---|
| 3 | // $Id: ctimer.h,v 1.4 2003-02-11 15:31:07 cmv Exp $
|
|---|
| 4 | //
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 | #ifndef CTIMER_SEEN
|
|---|
| 8 | #define CTIMER_SEEN
|
|---|
| 9 |
|
|---|
| 10 | #include "machdefs.h"
|
|---|
| 11 | #include <sys/types.h>
|
|---|
| 12 | #include <time.h>
|
|---|
| 13 | #include <iostream>
|
|---|
| 14 | #include <stdio.h>
|
|---|
| 15 | #include <string>
|
|---|
| 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.
|
|---|
| 25 | namespace SOPHYA {
|
|---|
| 26 |
|
|---|
| 27 | //! Simple chronometer class
|
|---|
| 28 | class Timer {
|
|---|
| 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...
|
|---|
| 41 | /*! To avoid not used object compiler warnings */
|
|---|
| 42 | void Nop() {}
|
|---|
| 43 |
|
|---|
| 44 | private:
|
|---|
| 45 | clock_t cpu0, cpuSplit;
|
|---|
| 46 | time_t elapse0, elapseSplit;
|
|---|
| 47 | string timerName;
|
|---|
| 48 | };
|
|---|
| 49 |
|
|---|
| 50 | } // namespace SOPHYA
|
|---|
| 51 |
|
|---|
| 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.