Version: 6.3.1

src/SMDS/chrono.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2006-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef _CHRONO_HXX_
00021 #define _CHRONO_HXX_
00022 
00023 #include <vector>
00024 #include <string>
00025 #include <iostream>
00026 #include <ctime>
00027 
00028 typedef struct acnt
00029 {
00030   char*  _ctrNames;
00031   int    _ctrLines;
00032   int    _ctrOccur;
00033   double _ctrCumul;
00034 } cntStruct;
00035 
00036 class counters
00037 {
00038 public:
00039   static cntStruct *_ctrs;
00040   counters(int nb);
00041   ~counters();
00042   static void stats();
00043 protected:
00044   static int _nbChrono;
00045 };
00046 
00047 class chrono
00048 {
00049 public:
00050   chrono(int i);
00051   ~chrono();
00052   void stop();
00053 protected:
00054   bool _run;
00055   int _ctr;
00056   clock_t _start, _end;
00057 };
00058 
00059 #ifdef CHRONODEF
00060 #define CHRONO(i) counters::_ctrs[i]._ctrNames = (char *)__FILE__; \
00061   counters::_ctrs[i]._ctrLines = __LINE__; \
00062   chrono aChrono##i(i);
00063 
00064 #define CHRONOSTOP(i) aChrono##i.stop();
00065 
00066 #else  // CHRONODEF
00067 
00068 #define CHRONO(i)
00069 #define CHRONOSTOP(i)
00070 
00071 #endif // CHRONODEF
00072 
00073 #endif // _CHRONO_HXX_
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS