1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VisuGUI_Timer.cxx
27 #include "VisuGUI_Timer.h"
29 #include "SUIT_Desktop.h"
31 #include "utilities.h"
34 static struct timezone *tz=(struct timezone*) malloc(sizeof(struct timezone));
36 //timezone *tz=_timezone;
40 # define CLK_TCK CLOCKS_PER_SEC
43 VisuGUI_Timer::VisuGUI_Timer() :
48 VisuGUI_Timer::~VisuGUI_Timer()
52 void VisuGUI_Timer::Start()
57 times(RefToInitialTMS);
58 gettimeofday(RefToInitialTimeB,tz);
62 SystemTimeToFileTime(&st, RefToInitialTMS);
63 time(RefToCurrentTimeB);
68 void VisuGUI_Timer::Stop()
72 times(RefToCurrentTMS);
73 int diffr_user = RefToCurrentTMS->tms_utime - RefToInitialTMS->tms_utime;
74 int diffr_sys = RefToCurrentTMS->tms_stime - RefToInitialTMS->tms_stime;
75 gettimeofday(RefToCurrentTimeB,tz);
77 static long aCLK_TCK=sysconf(_SC_CLK_TCK);
78 Cumul_user += (double) diffr_user / aCLK_TCK ;
79 Cumul_sys += (double) diffr_sys / aCLK_TCK ;
83 SystemTimeToFileTime(&st, RefToCurrentTMS);
84 Cumul_user += (int)(((ULARGE_INTEGER*)(RefToCurrentTMS))->QuadPart - ((ULARGE_INTEGER*)(RefToInitialTMS))->QuadPart) / 10000000;
85 Cumul_sys = Cumul_user;
86 time(RefToCurrentTimeB);
92 void VisuGUI_Timer::Reset() {
94 Cumul_user = Cumul_sys = 0. ;
97 QString VisuGUI_Timer::GetTime() {
98 bool StopSav = Stopped;
101 return QString::number( Cumul_user );
103 if (!StopSav) Start();