]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To impelement time profiling
authorapo <apo@opencascade.com>
Fri, 18 Nov 2005 14:14:14 +0000 (14:14 +0000)
committerapo <apo@opencascade.com>
Fri, 18 Nov 2005 14:14:14 +0000 (14:14 +0000)
src/CONVERTOR/VISU_ConvertorUtils.cxx
src/CONVERTOR/VISU_ConvertorUtils.hxx
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_MedConvertor.cxx

index fcfb6f9539fd6073d6c80c8670240a4b90af7c91..ac737d3785875596569a9f7fe49feaf336e80128 100644 (file)
 //  Module : VISU
 
 #include "VISU_ConvertorUtils.hxx"
+
 #include <vtkUnstructuredGridWriter.h>
+#include <vtkTimerLog.h>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
 
-namespace VISU{
+namespace VISU
+{
 
   void 
   WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName)
@@ -40,4 +49,20 @@ namespace VISU{
     aWriter->Delete();
   }
 
+  TTimerLog
+  ::TTimerLog(const std::string& theName):
+    myTimerLog(vtkTimerLog::New()),
+    myName(theName)
+  {
+    myCPUTime = myTimerLog->GetCPUTime();
+  }
+
+  TTimerLog
+  ::~TTimerLog()
+  {
+    myCPUTime = myTimerLog->GetCPUTime() - myCPUTime;
+    INITMSG(MYDEBUG,"~TTimerLog for "<<myName<<" takes "<<myCPUTime<<" secs\n");
+    myTimerLog->Delete();
+  }
+
 }
index 1ef42e369fbc1cee2e3853422c01a081b4536af6..124eb8d7ee1fe11d34581e1f8c6d4a3394fb8b79 100644 (file)
 #include "MED_Utilities.hxx"
 
 class vtkUnstructuredGrid;
+class vtkTimerLog;
 
 namespace VISU{
 
   void 
   WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName);
+
+  class TTimerLog
+  {
+    vtkTimerLog* myTimerLog;
+    double myCPUTime;
+    std::string myName;
+  public:
+    TTimerLog(const std::string& theName);
+    ~TTimerLog();
+  };
   
 }
 
index ad2a643c6e61fc80c6be989faaf62ed39477cca7..d8c2c0efc98acb88e49859a9f7a28fb4d70596be 100644 (file)
@@ -59,7 +59,7 @@ static int MYVTKDEBUG = 0;
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
 static int MYDEBUGWITHFILES = 0;
-//#define _DEXCEPT_
+#define _DEXCEPT_
 #else
 static int MYDEBUG = 0;
 static int MYDEBUGWITHFILES = 0;
index 4ab71595a40871b4480d725ca88a4e83c2104bbf..8961e2b6240ab1388c754247b15e671ba604c566 100644 (file)
@@ -53,7 +53,7 @@ static int MYMEMORYDEBUG = 0;
 static int MYTHREADDEBUG = 0;
 static int MY_FAMILY_DEBUG = 0;
 static int MY_GROUP_DEBUG = 0;
-//#define _DEXCEPT_
+#define _DEXCEPT_
 #else
 static int MYDEBUG = 0;
 static int MYVALUEDEBUG = 0;
@@ -312,6 +312,7 @@ namespace
              const MED::TGeom2Size& theGeom2Size,
              VISU::TMEDValForTime& theValForTime)
   {
+    TTimerLog aTimerLog("InitProfile");
     INITMSG(MYDEBUG,"InitProfile"<<endl);
     
     TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
@@ -355,6 +356,7 @@ namespace
              const MED::TGeom2Size& theGeom2Size,
              VISU::TMEDValForTime& theValForTime)
   {
+    TTimerLog aTimerLog("GetGaussKey");
     INITMSG(MYDEBUG,"GetGaussKey"<<endl);
 
     TGaussKey aGaussKey;
@@ -429,6 +431,7 @@ namespace
                const MED::TGeom2Size& theGeom2Size,
                VISU::TMEDValForTime& theValForTime)
   {
+    TTimerLog aTimerLog("InitGaussMesh");
     INITMSG(MYDEBUG,"InitGaussMesh"<<endl);
 
     if(theMeshOnEntity.myEntity == NODE_ENTITY)
@@ -482,6 +485,7 @@ namespace
                   const MED::TGeom2Size& theGeom2Size,
                   VISU::TMEDValForTime& theValForTime)
   {
+    TTimerLog aTimerLog("InitGaussProfile");
     INITMSG(MYDEBUG,"InitGaussProfile"<<endl);
 
     // The order of the function calls is important
@@ -510,6 +514,7 @@ namespace
                       const MED::PNodeInfo& theNodeInfo,
                       const MED::PWrapper& theMEDWrapper)
   {
+    TTimerLog aTimerLog("BuildMeshOnEntityMap");
     INITMSG(MYDEBUG,"BuildMeshOnEntityMap"<<endl);
     MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
     const std::string& aMeshName = theMesh->myName;
@@ -854,22 +859,24 @@ namespace
                const MED::TKey2Gauss& theKey2Gauss,
                MED::PWrapper theMEDWrapper)
   {
+    TTimerLog aTimerLog("BuildFieldMap");
     TInt aNbFields = theMEDWrapper->GetNbFields(); 
     MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
     const std::string& aMeshName = theMesh->myName;
     INITMSG(MYDEBUG,"BuildFieldMap: aNbFields = "<<aNbFields<<"\n");
     for(TInt iField = 1; iField <= aNbFields; iField++){
+      TTimerLog aTimerLog("BuildFieldMap - GetPFieldInfo");
       MED::PFieldInfo aFieldInfo = theMEDWrapper->GetPFieldInfo(aMeshInfo,iField);
       TInt aNbComp = aFieldInfo->GetNbComp();
       std::string aFieldName = aFieldInfo->GetName();
       
       MED::TGeom2Size aGeom2Size;
-      MED::EEntiteMaillage aMEntity;
+      MED::EEntiteMaillage aMEntity = MED::EEntiteMaillage(-1);
       TInt aNbTimeStamps = theMEDWrapper->GetNbTimeStamps(aFieldInfo,
                                                          theEntityInfo,
                                                          aMEntity,
                                                          aGeom2Size);
-      if(aNbTimeStamps < 1)
+      if(int(aMEntity) < 0 || aNbTimeStamps < 1)
        continue;
       
       TEntity aVEntity = MEDEntityToVTK(aMEntity);
@@ -895,32 +902,36 @@ namespace
       }
       
       for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){
+       TTimerLog aTimerLog("BuildFieldMap - GetPTimeStampInfo");
        MED::PTimeStampInfo aTimeStampInfo = theMEDWrapper->GetPTimeStampInfo(aFieldInfo,
                                                                              aMEntity,
                                                                              aGeom2Size,
                                                                              iTimeStamp);
        TFloat aDt = aTimeStampInfo->GetDt();
        std::string anUnitDt = aTimeStampInfo->GetUnitDt();
-       MED::PTimeStampVal aTimeStampVal = theMEDWrapper->GetPTimeStampVal(aTimeStampInfo,
-                                                                          theMKey2Profile,
-                                                                          theKey2Gauss);
-       TValField& aValField = aField->myValField;
-       PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime());
-       aValForTime->myId = iTimeStamp;
-       aValForTime->myFieldName = aField->myName;
-       aValForTime->myEntity = aField->myEntity;
-       aValForTime->myMeshName = aField->myMeshName;
-       aValForTime->myNbGauss = aTimeStampInfo->GetNbGauss();
-       aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
-       INITMSG(MYDEBUG,"aDt = '"<<aDt<<", "<<anUnitDt<<"'\n");
-       
-       InitGaussProfile(theMEDWrapper,
-                        aMeshInfo,
-                        aTimeStampVal,
-                        aMeshOnEntity,
-                        aMEntity,
-                        aGeom2Size,
-                        aValForTime);
+       {
+         TTimerLog aTimerLog("BuildFieldMap - GetPTimeStampVal");
+         MED::PTimeStampVal aTimeStampVal = theMEDWrapper->GetPTimeStampVal(aTimeStampInfo,
+                                                                            theMKey2Profile,
+                                                                            theKey2Gauss);
+         TValField& aValField = aField->myValField;
+         PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime());
+         aValForTime->myId = iTimeStamp;
+         aValForTime->myFieldName = aField->myName;
+         aValForTime->myEntity = aField->myEntity;
+         aValForTime->myMeshName = aField->myMeshName;
+         aValForTime->myNbGauss = aTimeStampInfo->GetNbGauss();
+         aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
+         INITMSG(MYDEBUG,"aDt = '"<<aDt<<", "<<anUnitDt<<"'\n");
+         
+         InitGaussProfile(theMEDWrapper,
+                          aMeshInfo,
+                          aTimeStampVal,
+                          aMeshOnEntity,
+                          aMEntity,
+                          aGeom2Size,
+                          aValForTime);
+       }
       }
     }
   }
@@ -935,6 +946,7 @@ namespace
                 const MED::TFamilyInfoSet& theFamilyInfoSet,
                 MED::PWrapper theMEDWrapper)
   {
+    TTimerLog aTimerLog("BuildFamilyMap");
     INITMSG(MYDEBUG,"BuildFamilyMap\n");
     MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
     MED::TEntity2FamilySet aEntity2FamilySet = MED::GetEntity2FamilySet(theMEDWrapper,theEntity2TGeom2ElemInfo,theFamilyInfoSet);
@@ -1004,7 +1016,8 @@ namespace
   BuildGroupMap(PMEDMesh theMesh,
                const MED::TFamilyInfoSet& theFamilyInfoSet)
   {
-    INITMSG(MYDEBUG,"BuildGroupMap:\n");
+    TTimerLog aTimerLog("BuildGroupMap");
+    INITMSG(MYDEBUG,"BuildGroupMap\n");
     TGroupMap& aGroupMap = theMesh->myGroupMap;
     MED::TGroupInfo aGroupInfo = MED::GetGroupInfo(theFamilyInfoSet);
     MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin();
@@ -1161,6 +1174,7 @@ VISU_Convertor*
 VISU_MedConvertor
 ::Build()
 {
+  TTimerLog aTimerLog("Build");
   MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
 
   MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(aMed);
@@ -1232,13 +1246,12 @@ VISU_MedConvertor
        BuildGroupMap(aMesh,
                      aFamilyInfoSet);
 #endif
-
        PCalculateMinMax aCalculateMinMax(new TCalculateMinMax(aMesh,
                                                               aEntityInfo,
                                                               aMKey2Profile,
                                                               aKey2Gauss,
                                                               aMed));
-       
+
        boost::thread aThread(boost::bind(&CalculateMinMax,aCalculateMinMax));
 #ifndef _DEXCEPT_
       }catch(std::exception& exc){
@@ -1267,6 +1280,7 @@ VISU_MedConvertor
 ::LoadMeshOnEntity(VISU::PMeshImpl theMesh,
                   VISU::PMeshOnEntityImpl theMeshOnEntity)
 {
+  TTimerLog aTimerLog("LoadMeshOnEntity");
   MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
   const TEntity& anEntity = theMeshOnEntity->myEntity;
 
@@ -1289,6 +1303,7 @@ VISU_MedConvertor
                     VISU::PMeshOnEntityImpl theMeshOnEntity, 
                     VISU::PFamilyImpl theFamily)
 {
+  TTimerLog aTimerLog("LoadFamilyOnEntity");
   MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
   const TEntity& anEntity = theMeshOnEntity->myEntity;
 
@@ -1310,6 +1325,7 @@ VISU_MedConvertor
 ::LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
                  const VISU::TFamilySet& theFamilySet)
 {
+  TTimerLog aTimerLog("LoadMeshOnGroup");
   MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
   int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
   TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
@@ -1337,6 +1353,7 @@ VISU_MedConvertor
                       VISU::PFieldImpl theField, 
                       VISU::PValForTimeImpl theValForTime)
 {
+  TTimerLog aTimerLog("LoadValForTimeOnMesh");
   MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
 
   const TEntity& anEntity = theMeshOnEntity->myEntity;
@@ -1358,6 +1375,7 @@ VISU_MedConvertor
                           VISU::PFieldImpl theField, 
                           VISU::PValForTimeImpl theValForTime)
 {
+  TTimerLog aTimerLog("LoadValForTimeOnGaussPts");
   MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
 
   const TEntity& anEntity = theMeshOnEntity->myEntity;
@@ -1376,6 +1394,7 @@ VISU_MedConvertor
 ::LoadPoints(const MED::PWrapper& theMed,
             VISU::PMEDMesh theMesh) 
 {
+  TTimerLog aTimerLog("LoadValForTimeOnGaussPts");
   try{
     //Check on existing family
     PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
@@ -1440,6 +1459,7 @@ VISU_MedConvertor
                     const VISU::PMEDMesh theMesh, 
                     const VISU::PMEDFamily theFamily) 
 {
+  TTimerLog aTimerLog("LoadPointsOnFamily");
   try{
     if(theFamily->myIsDone) 
       return 0;
@@ -1477,6 +1497,7 @@ VISU_MedConvertor
                    const VISU::PMEDMesh theMesh,
                    const VISU::PMEDMeshOnEntity theMeshOnEntity)
 {
+  TTimerLog aTimerLog("LoadCellsOnEntity");
 #ifndef _DEXCEPT_
   try{
 #endif
@@ -1703,6 +1724,7 @@ VISU_MedConvertor
                    const VISU::PMEDMeshOnEntity theMeshOnEntity,
                    const VISU::PMEDFamily theFamily)
 {
+  TTimerLog aTimerLog("LoadCellsOnFamily");
 #ifndef _DEXCEPT_
   try{
 #endif
@@ -1776,6 +1798,7 @@ LoadProfile(const MED::PWrapper& theMed,
            VISU::TMEDValForTime& theValForTime,
            VISU::TMEDMeshOnEntity& theMeshOnEntity)
 {
+  TTimerLog aTimerLog("LoadProfile");
   INITMSG(MYDEBUG,"LoadProfile"<<endl);
 
   PMEDProfile aProfile = theValForTime.myProfile;
@@ -1855,6 +1878,7 @@ LoadGaussMesh(const MED::PWrapper& theMed,
              VISU::TMEDValForTime& theValForTime,
              VISU::TMEDMeshOnEntity& theMeshOnEntity)
 {
+  TTimerLog aTimerLog("LoadGaussMesh");
   INITMSG(MYDEBUG,"LoadGaussMesh"<<endl);
 
   PMEDGaussMesh aGaussMesh = theValForTime.myGaussMesh;
@@ -2026,6 +2050,7 @@ LoadValForTime(const MED::PWrapper& theMed,
               bool theIsGauss,
               bool& theIsDone)
 {
+  TTimerLog aTimerLog("LoadValForTime");
   INITMSG(MYDEBUG,"LoadValForTime - theIsGauss = "<<theIsGauss<<endl);
 
   //Check on loading already done
@@ -2144,6 +2169,7 @@ VISU_MedConvertor
                       VISU::PMEDField theField, 
                       VISU::PMEDValForTime theValForTime)
 {
+  TTimerLog aTimerLog("LoadValForTimeOnMesh");
   PIDMapperFilter anIDMapperFilter = theValForTime->myIDMapperFilter;
   return LoadValForTime(theMed,
                        theMesh,
@@ -2164,6 +2190,7 @@ VISU_MedConvertor
                           VISU::PMEDField theField, 
                           VISU::PMEDValForTime theValForTime)
 {
+  TTimerLog aTimerLog("LoadValForTimeOnGaussPts");
   PGaussPtsIDFilter aGaussPtsIDFilter = theValForTime->myGaussPtsIDFilter;
   return LoadValForTime(theMed,
                        theMesh,