SALOME documentation central

src/Utils/Utils_Timer.hxx

00001 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 //  This library is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU Lesser General Public
00008 //  License as published by the Free Software Foundation; either
00009 //  version 2.1 of the License.
00010 //
00011 //  This library is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 //  Lesser General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU Lesser General Public
00017 //  License along with this library; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //  SALOME Utils : general SALOME's definitions and tools
00023 //  File   : Utils_Timer.hxx
00024 //  Module : SALOME
00025 //
00026 #include "SALOME_Utils.hxx"
00027 
00028 #include <stdlib.h>
00029 #include <time.h>
00030 
00031 #ifndef WIN32
00032 # include <sys/times.h>
00033 # include <sys/time.h>
00034 # include <unistd.h>
00035 #else
00036 # include <windows.h>
00037 # include <time.h>
00038 # include <sys/timeb.h>
00039 #define _POSIX_
00040 #endif
00041 
00042 class UTILS_EXPORT Utils_Timer {
00043  public:
00044   Utils_Timer();
00045   virtual ~Utils_Timer();
00046   void Start();
00047   void Stop();
00048   void Reset();
00049   void Show();
00050   void ShowAbsolute();
00051  protected:
00052   double Cumul_user;
00053   double Cumul_sys;
00054   bool Stopped;
00055 #ifndef WIN32
00056   tms *RefToCurrentTMS, *RefToInitialTMS;
00057   timeval *RefToCurrentTimeB, *RefToInitialTimeB;
00058 #else
00059   FILETIME *RefToCurrentTMS, *RefToInitialTMS;
00060   time_t *RefToCurrentTimeB, *RefToInitialTimeB;
00061 #endif
00062 };