From 2f4dfe59a9e9999c0b6334f8db4d22ab7bbc8108 Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 20 Oct 2005 14:07:22 +0000 Subject: [PATCH] Added timer for counting cpu time of the Import operation. --- src/VISUGUI/Makefile.in | 3 +- src/VISUGUI/VisuGUI.cxx | 10 +++- src/VISUGUI/VisuGUI_Timer.cxx | 103 ++++++++++++++++++++++++++++++++++ src/VISUGUI/VisuGUI_Timer.h | 43 ++++++++++++++ 4 files changed, 156 insertions(+), 3 deletions(-) create mode 100644 src/VISUGUI/VisuGUI_Timer.cxx create mode 100644 src/VISUGUI/VisuGUI_Timer.h diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index 3e9f92da..84579bf2 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -69,7 +69,8 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_CutLinesDlg.cxx \ VisuGUI_CutPlanesDlg.cxx \ VisuGUI_StreamLinesDlg.cxx \ - VisuGUI_VectorsDlg.cxx + VisuGUI_VectorsDlg.cxx \ + VisuGUI_Timer.cxx LIB_MOC = VisuGUI.h \ VisuGUI_Module.h \ diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index b3b56888..def9b9fc 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -131,6 +131,8 @@ #include "VisuGUI_ActionsDef.h" +#include "VisuGUI_Timer.h" + using namespace VISU; #ifdef _DEBUG_ @@ -158,6 +160,9 @@ void VisuGUI:: OnImportFromFile() { + VisuGUI_Timer aTimer; + aTimer.Start(); + if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()"); CheckLock(GetCStudy(GetAppStudy(this))); SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); @@ -173,7 +178,7 @@ OnImportFromFile() tr("MEN_IMPORT_FROM_FILE"), true); if(aFileInfo.exists()) { - application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." ); + application()->putInfo( "Importing From File " + aFileInfo.filePath() + "...", -1 ); VISU::Result_var aResult; bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false); @@ -201,8 +206,9 @@ OnImportFromFile() tr("ERR_ERROR_IN_THE_FILE"), tr("BUT_OK")); }else{ - application()->putInfo(aFileInfo.filePath() + tr("INF_DONE")); UpdateObjBrowser(this); + application()->putInfo(aFileInfo.filePath() + tr("INF_DONE") + + " in " + aTimer.GetTime() + " seconds", -1 ); } } } diff --git a/src/VISUGUI/VisuGUI_Timer.cxx b/src/VISUGUI/VisuGUI_Timer.cxx new file mode 100644 index 00000000..ce88bbfc --- /dev/null +++ b/src/VISUGUI/VisuGUI_Timer.cxx @@ -0,0 +1,103 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_Timer.cxx +// Module : SALOME + +#include "VisuGUI_Timer.h" + +#include "SUIT_Desktop.h" + +#include "utilities.h" + +#ifndef WNT +static struct timezone *tz=(struct timezone*) malloc(sizeof(struct timezone)); +#else +//timezone *tz=_timezone; +#endif + +#ifndef CLK_TCK +# define CLK_TCK CLOCKS_PER_SEC +#endif + +VisuGUI_Timer::VisuGUI_Timer() : + Utils_Timer() +{ +} + +VisuGUI_Timer::~VisuGUI_Timer() +{ +} + +void VisuGUI_Timer::Start() +{ + if (Stopped) { + Stopped = 0; +#ifndef WNT + times(RefToInitialTMS); + gettimeofday(RefToInitialTimeB,tz); +#else + SYSTEMTIME st; + GetSystemTime(&st); + SystemTimeToFileTime(&st, RefToInitialTMS); + time(RefToCurrentTimeB); +#endif + } +} + +void VisuGUI_Timer::Stop() +{ + if (!Stopped) { +#ifndef WNT + times(RefToCurrentTMS); + int diffr_user = RefToCurrentTMS->tms_utime - RefToInitialTMS->tms_utime; + int diffr_sys = RefToCurrentTMS->tms_stime - RefToInitialTMS->tms_stime; + gettimeofday(RefToCurrentTimeB,tz); + + Cumul_user += (double) diffr_user / CLK_TCK ; + Cumul_sys += (double) diffr_sys / CLK_TCK ; +#else + SYSTEMTIME st; + GetSystemTime(&st); + SystemTimeToFileTime(&st, RefToCurrentTMS); + Cumul_user += (int)(((ULARGE_INTEGER*)(RefToCurrentTMS))->QuadPart - ((ULARGE_INTEGER*)(RefToInitialTMS))->QuadPart) / 10000000; + Cumul_sys = Cumul_user; + time(RefToCurrentTimeB); +#endif + Stopped = 1; + } +} + +void VisuGUI_Timer::Reset() { + Stopped = 1; + Cumul_user = Cumul_sys = 0. ; +} + +QString VisuGUI_Timer::GetTime() { + bool StopSav = Stopped; + if (!StopSav) Stop(); + + return QString::number( Cumul_user ); + + if (!StopSav) Start(); +} diff --git a/src/VISUGUI/VisuGUI_Timer.h b/src/VISUGUI/VisuGUI_Timer.h new file mode 100644 index 00000000..bbfb7e57 --- /dev/null +++ b/src/VISUGUI/VisuGUI_Timer.h @@ -0,0 +1,43 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_Timer.h +// Module : SALOME + +#include + +#include + +class VisuGUI_Timer : public Utils_Timer +{ + public: + VisuGUI_Timer(); + virtual ~VisuGUI_Timer(); + + public: + void Start(); + void Stop(); + void Reset(); + + QString GetTime(); +}; -- 2.39.2