00001 // Copyright (C) 2007-2011 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 00023 // SALOME Utils : general SALOME's definitions and tools 00024 // File : Utils_Timer.hxx 00025 // Module : SALOME 00026 // 00027 #include "SALOME_Utils.hxx" 00028 00029 #include <stdlib.h> 00030 #include <time.h> 00031 00032 #ifndef WIN32 00033 # include <sys/times.h> 00034 # include <sys/time.h> 00035 # include <unistd.h> 00036 #else 00037 # include <windows.h> 00038 # include <time.h> 00039 # include <sys/timeb.h> 00040 #define _POSIX_ 00041 #endif 00042 00043 class UTILS_EXPORT Utils_Timer { 00044 public: 00045 Utils_Timer(); 00046 virtual ~Utils_Timer(); 00047 void Start(); 00048 void Stop(); 00049 void Reset(); 00050 void Show(); 00051 void ShowAbsolute(); 00052 protected: 00053 double Cumul_user; 00054 double Cumul_sys; 00055 bool Stopped; 00056 #ifndef WIN32 00057 tms *RefToCurrentTMS, *RefToInitialTMS; 00058 timeval *RefToCurrentTimeB, *RefToInitialTimeB; 00059 #else 00060 FILETIME *RefToCurrentTMS, *RefToInitialTMS; 00061 time_t *RefToCurrentTimeB, *RefToInitialTimeB; 00062 #endif 00063 };