Back to index

salome-smesh  6.5.0
chrono.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2006-2012  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 "SMESH_SMDS.hxx"
00024 
00025 #include <vector>
00026 #include <string>
00027 #include <iostream>
00028 #include <ctime>
00029 
00030 typedef struct acnt
00031 {
00032   char*  _ctrNames;
00033   int    _ctrLines;
00034   int    _ctrOccur;
00035   double _ctrCumul;
00036 } cntStruct;
00037 
00038 class SMDS_EXPORT counters
00039 {
00040 public:
00041   static cntStruct *_ctrs;
00042   counters(int nb);
00043   ~counters();
00044   static void stats();
00045 protected:
00046   static int _nbChrono;
00047 };
00048 
00049 class SMDS_EXPORT chrono
00050 {
00051 public:
00052   chrono(int i);
00053   ~chrono();
00054   void stop();
00055 protected:
00056   bool _run;
00057   int _ctr;
00058   clock_t _start, _end;
00059 };
00060 
00061 #ifdef CHRONODEF
00062 #define CHRONO(i) counters::_ctrs[i]._ctrNames = (char *)__FILE__; \
00063   counters::_ctrs[i]._ctrLines = __LINE__; \
00064   chrono aChrono##i(i);
00065 
00066 #define CHRONOSTOP(i) aChrono##i.stop();
00067 
00068 #else  // CHRONODEF
00069 
00070 #define CHRONO(i)
00071 #define CHRONOSTOP(i)
00072 
00073 #endif // CHRONODEF
00074 
00075 #endif // _CHRONO_HXX_