From: caremoli Date: Thu, 3 Jul 2008 14:23:39 +0000 (+0000) Subject: CCAR: add TIMING macros and optimizations in SOCC_Viewer, GEOMDisplayer, GEOMClient X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fda5de2068d28d288518d4e93aaa4c4eec9f98ae;p=modules%2Fgeom.git CCAR: add TIMING macros and optimizations in SOCC_Viewer, GEOMDisplayer, GEOMClient --- diff --git a/src/GEOMClient/GEOM_Client.cxx b/src/GEOMClient/GEOM_Client.cxx index 5f89234b9..1ec22d5f1 100644 --- a/src/GEOMClient/GEOM_Client.cxx +++ b/src/GEOMClient/GEOM_Client.cxx @@ -60,6 +60,14 @@ using namespace std; #define HST_CLIENT_LEN 256 +#include +static long tt0; +static long tcount=0; +static long cumul; +#define START_TIMING timeval tv; gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000; +#define END_TIMING(NUMBER) \ + tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \ + if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; } //======================================================================= @@ -120,6 +128,17 @@ GEOM_Client::GEOM_Client(Engines::Container_ptr client) //======================================================================= Standard_Integer GEOM_Client::Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S ) { + //CCAR +#if 1 + if(_myIndexes.count(IOR)==0) + return 0; + else + { + Standard_Integer i =_myIndexes[IOR]; + S = myShapes.Value(i); + return i; + } +#else for ( Standard_Integer i = 1; i<= myIORs.Length(); i++ ) { if (myIORs.Value(i).IsEqual(IOR)) { S = myShapes.Value(i); @@ -127,6 +146,7 @@ Standard_Integer GEOM_Client::Find( const TCollection_AsciiString& IOR, TopoDS_S } } return 0; +#endif } //======================================================================= @@ -152,6 +172,7 @@ void GEOM_Client::Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& { myIORs.Append(IOR); myShapes.Append(S); + _myIndexes[IOR]=_myIndexes.size()+1; } //======================================================================= @@ -168,6 +189,7 @@ void GEOM_Client::RemoveShapeFromBuffer( const TCollection_AsciiString& IOR) if( anIndex != 0 ) { myIORs.Remove(anIndex) ; myShapes.Remove(anIndex) ; + _myIndexes.erase(IOR); } return ; } @@ -183,6 +205,7 @@ void GEOM_Client::ClearClientBuffer() return ; myIORs.Clear() ; myShapes.Clear() ; + _myIndexes.clear(); return ; } @@ -202,6 +225,7 @@ unsigned int GEOM_Client::BufferLength() //======================================================================= TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape ) { + START_TIMING TopoDS_Shape S; TCollection_AsciiString IOR = geom->GetStringFromIOR(aShape); Standard_Integer anIndex = Find(IOR, S); @@ -212,6 +236,7 @@ TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_p if (aShape->IsMainShape()) { S = Load(geom, aShape); Bind(IOR, S); +END_TIMING(200) return S; } @@ -241,5 +266,6 @@ TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_p S = aCompound; } Bind(IOR, S); +END_TIMING(200) return S; } diff --git a/src/GEOMClient/GEOM_Client.hxx b/src/GEOMClient/GEOM_Client.hxx index 161fcc105..46e31374a 100644 --- a/src/GEOMClient/GEOM_Client.hxx +++ b/src/GEOMClient/GEOM_Client.hxx @@ -70,6 +70,8 @@ class TopoDS_Shape; #define GEOMCLIENT_EXPORT #endif +#include +#include //===================================================================== // GEOM_Client : class definition //===================================================================== @@ -116,6 +118,7 @@ private: // TColStd_SequenceOfAsciiString myIORs ; TopTools_SequenceOfShape myShapes ; + std::map< TCollection_AsciiString , int > _myIndexes; long pid_client; }; diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 55e318612..7cafd602f 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -97,6 +97,18 @@ #include "GEOMImpl_Types.hxx" +#include "OCCViewer_ViewModel.h" +#include "SALOME_InteractiveObject.hxx" +#include +static long tt0; +static long tcount=0; +static long cumul; +#define START_TIMING timeval tv; gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000; +#define END_TIMING(NUMBER) \ + tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \ + if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; } + + using namespace std; //================================================================ @@ -305,11 +317,13 @@ void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO, const bool updateViewer, SALOME_View* theViewFrame ) { + //START_TIMING SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView(); if ( vf ) { SALOME_Prs* prs = buildPresentation( theIO->getEntry(), vf ); + //END_TIMING(1) if ( prs ) { vf->BeforeDisplay( this ); @@ -785,6 +799,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) //================================================================= void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) { + START_TIMING SVTK_Prs* vtkPrs = dynamic_cast( prs ); if ( !vtkPrs || myShape.IsNull() ) return; @@ -880,6 +895,7 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) aProp->Delete(); theActors->Delete(); + END_TIMING(50) } //================================================================= @@ -954,7 +970,12 @@ SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry, if ( myViewFrame ) { + //CCAR +#if 1 + prs = LightApp_Displayer::buildPresentation( QString(), theViewFrame ); +#else prs = LightApp_Displayer::buildPresentation( entry, theViewFrame ); +#endif if ( prs ) { Handle( SALOME_InteractiveObject ) theIO = new SALOME_InteractiveObject(); diff --git a/src/GEOMGUI/GeometryGUI_Swig.cxx b/src/GEOMGUI/GeometryGUI_Swig.cxx index 57df497a6..c3e7d6aaf 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.cxx +++ b/src/GEOMGUI/GeometryGUI_Swig.cxx @@ -73,6 +73,15 @@ #include CORBA_SERVER_HEADER(GEOM_Gen) #include +#include +static long tt0; +static long tcount=0; +static long cumul; +#define START_TIMING timeval tv; gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000; +#define END_TIMING(NUMBER) \ + tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \ + if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; } + using namespace std; @@ -124,6 +133,7 @@ void GEOM_Swig::createAndDisplayGO (const char* Entry, bool isUpdated) {} virtual void Execute() { + START_TIMING SUIT_Application* app = SUIT_Session::session()->activeApplication(); if (!app) return; @@ -216,6 +226,7 @@ void GEOM_Swig::createAndDisplayGO (const char* Entry, bool isUpdated) } } } + END_TIMING(200) } }; diff --git a/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx b/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx index cba3e36c5..7b21b9a14 100644 --- a/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx @@ -39,6 +39,15 @@ #include #include #include +#include +static long tt0; +static long tcount=0; +static long cumul; +#define START_TIMING timeval tv; gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000; +#define END_TIMING(NUMBER) \ + tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \ + if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; } + //======================================================================= //function : GetID @@ -65,6 +74,7 @@ GEOMImpl_CylinderDriver::GEOMImpl_CylinderDriver() //======================================================================= Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const { + START_TIMING if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); @@ -120,6 +130,7 @@ Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const aFunction->SetValue(aShape); log.SetTouched(Label()); + END_TIMING(200) return 1; } diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index a1c554544..412c5e30f 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -63,6 +63,15 @@ #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC +#include +static long tt0; +static long tcount=0; +static long cumul; +#define START_TIMING timeval tv; gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000; +#define END_TIMING(NUMBER) \ + tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \ + if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; } + //============================================================================= /*! @@ -251,6 +260,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEO Handle(GEOM_Object) theVec, double theR, double theH) { + START_TIMING + SetErrorCode(KO); if (thePnt.IsNull() || theVec.IsNull()) return NULL; @@ -299,6 +310,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEO << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")"; SetErrorCode(OK); + END_TIMING(200) return aCylinder; } diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index 4a89a99bc..bc6f7ee8e 100644 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -50,6 +50,15 @@ #include #include "SALOMEDS_Tool.hxx" +#include +static long tt0; +static long tcount=0; +static long cumul; +#define START_TIMING timeval tv; gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000; +#define END_TIMING(NUMBER) \ + tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \ + if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; } + //============================================================================ // function : GEOM_Gen_i() @@ -527,6 +536,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy, const char* theName, GEOM::GEOM_Object_ptr theFather) { + START_TIMING SALOMEDS::SObject_var aResultSO; if(theObject->_is_nil() || theStudy->_is_nil()) return aResultSO; @@ -558,6 +568,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aResultSO); aStudyBuilder->Addreference(aSubSO, aSO); } + END_TIMING(200) return aResultSO._retn(); } diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index 55160f0fb..2b958c715 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -27,6 +27,15 @@ #include "GEOM_Engine.hxx" #include "GEOM_Object.hxx" +#include +static long tt0; +static long tcount=0; +static long cumul; +#define START_TIMING timeval tv; gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000; +#define END_TIMING(NUMBER) \ + tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \ + if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; } + //============================================================================= /*! @@ -111,6 +120,7 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeBoxTwoPnt GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRH (CORBA::Double theR, CORBA::Double theH) { + START_TIMING GEOM::GEOM_Object_var aGEOMObject; //Set a not done flag @@ -121,6 +131,7 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRH (CORBA::Double th if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + END_TIMING(200) return GetObject(anObject); } @@ -134,6 +145,7 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderPntVecRH CORBA::Double theR, CORBA::Double theH) { GEOM::GEOM_Object_var aGEOMObject; + //START_TIMING //Set a not done flag GetOperations()->SetNotDone(); @@ -153,6 +165,7 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderPntVecRH if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + //END_TIMING(200) return GetObject(anObject); } diff --git a/src/OBJECT/GEOM_AssemblyBuilder.cxx b/src/OBJECT/GEOM_AssemblyBuilder.cxx index 5a0fa17a3..b2652c94a 100644 --- a/src/OBJECT/GEOM_AssemblyBuilder.cxx +++ b/src/OBJECT/GEOM_AssemblyBuilder.cxx @@ -51,6 +51,15 @@ #include #include "utilities.h" +#include +static long tt0; +static long tcount=0; +static long cumul; +#define START_TIMING timeval tv; gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000; +#define END_TIMING(NUMBER) \ + tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \ + if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; } + using namespace std; // SALOME @@ -254,7 +263,9 @@ vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShap for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) { + START_TIMING GEOM_Actor* FaceActor = GEOM_Actor::New(); + END_TIMING(450) FaceActor->SetShadingProperty(FaceProp); FaceActor->SetWireframeProperty(IsoProp);