From 22251b4b7f340a39c5f7bd57d520bcebef9de6bb Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 18 Nov 2005 14:14:14 +0000 Subject: [PATCH] To impelement time profiling --- src/CONVERTOR/VISU_ConvertorUtils.cxx | 27 ++++++++- src/CONVERTOR/VISU_ConvertorUtils.hxx | 11 ++++ src/CONVERTOR/VISU_Convertor_impl.cxx | 2 +- src/CONVERTOR/VISU_MedConvertor.cxx | 79 ++++++++++++++++++--------- 4 files changed, 91 insertions(+), 28 deletions(-) diff --git a/src/CONVERTOR/VISU_ConvertorUtils.cxx b/src/CONVERTOR/VISU_ConvertorUtils.cxx index fcfb6f95..ac737d37 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.cxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.cxx @@ -25,9 +25,18 @@ // Module : VISU #include "VISU_ConvertorUtils.hxx" + #include +#include + +#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 "<Delete(); + } + } diff --git a/src/CONVERTOR/VISU_ConvertorUtils.hxx b/src/CONVERTOR/VISU_ConvertorUtils.hxx index 1ef42e36..124eb8d7 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.hxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.hxx @@ -34,11 +34,22 @@ #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(); + }; } diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index ad2a643c..d8c2c0ef 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -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; diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 4ab71595..8961e2b6 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -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"<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 = "<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 = '"<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 = '"<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"<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, -- 2.39.2