CCAR: add TIMING macros and optimizations in SOCC_Viewer, GEOMDisplayer, GEOMClient

This commit is contained in:
caremoli 2008-07-03 14:23:39 +00:00
parent 4e75f03828
commit fda5de2068
9 changed files with 119 additions and 0 deletions

View File

@ -60,6 +60,14 @@ using namespace std;
#define HST_CLIENT_LEN 256 #define HST_CLIENT_LEN 256
#include <sys/time.h>
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 ) 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++ ) { for ( Standard_Integer i = 1; i<= myIORs.Length(); i++ ) {
if (myIORs.Value(i).IsEqual(IOR)) { if (myIORs.Value(i).IsEqual(IOR)) {
S = myShapes.Value(i); S = myShapes.Value(i);
@ -127,6 +146,7 @@ Standard_Integer GEOM_Client::Find( const TCollection_AsciiString& IOR, TopoDS_S
} }
} }
return 0; return 0;
#endif
} }
//======================================================================= //=======================================================================
@ -152,6 +172,7 @@ void GEOM_Client::Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape&
{ {
myIORs.Append(IOR); myIORs.Append(IOR);
myShapes.Append(S); myShapes.Append(S);
_myIndexes[IOR]=_myIndexes.size()+1;
} }
//======================================================================= //=======================================================================
@ -168,6 +189,7 @@ void GEOM_Client::RemoveShapeFromBuffer( const TCollection_AsciiString& IOR)
if( anIndex != 0 ) { if( anIndex != 0 ) {
myIORs.Remove(anIndex) ; myIORs.Remove(anIndex) ;
myShapes.Remove(anIndex) ; myShapes.Remove(anIndex) ;
_myIndexes.erase(IOR);
} }
return ; return ;
} }
@ -183,6 +205,7 @@ void GEOM_Client::ClearClientBuffer()
return ; return ;
myIORs.Clear() ; myIORs.Clear() ;
myShapes.Clear() ; myShapes.Clear() ;
_myIndexes.clear();
return ; 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 ) TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape )
{ {
START_TIMING
TopoDS_Shape S; TopoDS_Shape S;
TCollection_AsciiString IOR = geom->GetStringFromIOR(aShape); TCollection_AsciiString IOR = geom->GetStringFromIOR(aShape);
Standard_Integer anIndex = Find(IOR, S); 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()) { if (aShape->IsMainShape()) {
S = Load(geom, aShape); S = Load(geom, aShape);
Bind(IOR, S); Bind(IOR, S);
END_TIMING(200)
return S; return S;
} }
@ -241,5 +266,6 @@ TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_p
S = aCompound; S = aCompound;
} }
Bind(IOR, S); Bind(IOR, S);
END_TIMING(200)
return S; return S;
} }

View File

@ -70,6 +70,8 @@ class TopoDS_Shape;
#define GEOMCLIENT_EXPORT #define GEOMCLIENT_EXPORT
#endif #endif
#include <TCollection_AsciiString.hxx>
#include <map>
//===================================================================== //=====================================================================
// GEOM_Client : class definition // GEOM_Client : class definition
//===================================================================== //=====================================================================
@ -116,6 +118,7 @@ private:
// //
TColStd_SequenceOfAsciiString myIORs ; TColStd_SequenceOfAsciiString myIORs ;
TopTools_SequenceOfShape myShapes ; TopTools_SequenceOfShape myShapes ;
std::map< TCollection_AsciiString , int > _myIndexes;
long pid_client; long pid_client;
}; };

View File

@ -97,6 +97,18 @@
#include "GEOMImpl_Types.hxx" #include "GEOMImpl_Types.hxx"
#include "OCCViewer_ViewModel.h"
#include "SALOME_InteractiveObject.hxx"
#include <sys/time.h>
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; using namespace std;
//================================================================ //================================================================
@ -305,11 +317,13 @@ void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO,
const bool updateViewer, const bool updateViewer,
SALOME_View* theViewFrame ) SALOME_View* theViewFrame )
{ {
//START_TIMING
SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView(); SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
if ( vf ) if ( vf )
{ {
SALOME_Prs* prs = buildPresentation( theIO->getEntry(), vf ); SALOME_Prs* prs = buildPresentation( theIO->getEntry(), vf );
//END_TIMING(1)
if ( prs ) if ( prs )
{ {
vf->BeforeDisplay( this ); vf->BeforeDisplay( this );
@ -785,6 +799,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
//================================================================= //=================================================================
void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
{ {
START_TIMING
SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs ); SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
if ( !vtkPrs || myShape.IsNull() ) if ( !vtkPrs || myShape.IsNull() )
return; return;
@ -880,6 +895,7 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
aProp->Delete(); aProp->Delete();
theActors->Delete(); theActors->Delete();
END_TIMING(50)
} }
//================================================================= //=================================================================
@ -954,7 +970,12 @@ SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry,
if ( myViewFrame ) if ( myViewFrame )
{ {
//CCAR
#if 1
prs = LightApp_Displayer::buildPresentation( QString(), theViewFrame );
#else
prs = LightApp_Displayer::buildPresentation( entry, theViewFrame ); prs = LightApp_Displayer::buildPresentation( entry, theViewFrame );
#endif
if ( prs ) if ( prs )
{ {
Handle( SALOME_InteractiveObject ) theIO = new SALOME_InteractiveObject(); Handle( SALOME_InteractiveObject ) theIO = new SALOME_InteractiveObject();

View File

@ -73,6 +73,15 @@
#include CORBA_SERVER_HEADER(GEOM_Gen) #include CORBA_SERVER_HEADER(GEOM_Gen)
#include <vtkRenderer.h> #include <vtkRenderer.h>
#include <sys/time.h>
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; using namespace std;
@ -124,6 +133,7 @@ void GEOM_Swig::createAndDisplayGO (const char* Entry, bool isUpdated)
{} {}
virtual void Execute() virtual void Execute()
{ {
START_TIMING
SUIT_Application* app = SUIT_Session::session()->activeApplication(); SUIT_Application* app = SUIT_Session::session()->activeApplication();
if (!app) return; if (!app) return;
@ -216,6 +226,7 @@ void GEOM_Swig::createAndDisplayGO (const char* Entry, bool isUpdated)
} }
} }
} }
END_TIMING(200)
} }
}; };

View File

@ -39,6 +39,15 @@
#include <StdFail_NotDone.hxx> #include <StdFail_NotDone.hxx>
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
#include <gp.hxx> #include <gp.hxx>
#include <sys/time.h>
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 //function : GetID
@ -65,6 +74,7 @@ GEOMImpl_CylinderDriver::GEOMImpl_CylinderDriver()
//======================================================================= //=======================================================================
Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const
{ {
START_TIMING
if (Label().IsNull()) return 0; if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
@ -120,6 +130,7 @@ Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const
aFunction->SetValue(aShape); aFunction->SetValue(aShape);
log.SetTouched(Label()); log.SetTouched(Label());
END_TIMING(200)
return 1; return 1;
} }

View File

@ -63,6 +63,15 @@
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
#include <sys/time.h>
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, Handle(GEOM_Object) theVec,
double theR, double theH) double theR, double theH)
{ {
START_TIMING
SetErrorCode(KO); SetErrorCode(KO);
if (thePnt.IsNull() || theVec.IsNull()) return NULL; if (thePnt.IsNull() || theVec.IsNull()) return NULL;
@ -299,6 +310,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEO
<< thePnt << ", " << theVec << ", " << theR << ", " << theH << ")"; << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
SetErrorCode(OK); SetErrorCode(OK);
END_TIMING(200)
return aCylinder; return aCylinder;
} }

View File

@ -50,6 +50,15 @@
#include <OSD.hxx> #include <OSD.hxx>
#include "SALOMEDS_Tool.hxx" #include "SALOMEDS_Tool.hxx"
#include <sys/time.h>
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() // function : GEOM_Gen_i()
@ -527,6 +536,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy,
const char* theName, const char* theName,
GEOM::GEOM_Object_ptr theFather) GEOM::GEOM_Object_ptr theFather)
{ {
START_TIMING
SALOMEDS::SObject_var aResultSO; SALOMEDS::SObject_var aResultSO;
if(theObject->_is_nil() || theStudy->_is_nil()) return 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); SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aResultSO);
aStudyBuilder->Addreference(aSubSO, aSO); aStudyBuilder->Addreference(aSubSO, aSO);
} }
END_TIMING(200)
return aResultSO._retn(); return aResultSO._retn();
} }

View File

@ -27,6 +27,15 @@
#include "GEOM_Engine.hxx" #include "GEOM_Engine.hxx"
#include "GEOM_Object.hxx" #include "GEOM_Object.hxx"
#include <sys/time.h>
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, GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRH (CORBA::Double theR,
CORBA::Double theH) CORBA::Double theH)
{ {
START_TIMING
GEOM::GEOM_Object_var aGEOMObject; GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag //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()) if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn(); return aGEOMObject._retn();
END_TIMING(200)
return GetObject(anObject); return GetObject(anObject);
} }
@ -134,6 +145,7 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderPntVecRH
CORBA::Double theR, CORBA::Double theH) CORBA::Double theR, CORBA::Double theH)
{ {
GEOM::GEOM_Object_var aGEOMObject; GEOM::GEOM_Object_var aGEOMObject;
//START_TIMING
//Set a not done flag //Set a not done flag
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
@ -153,6 +165,7 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderPntVecRH
if (!GetOperations()->IsDone() || anObject.IsNull()) if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn(); return aGEOMObject._retn();
//END_TIMING(200)
return GetObject(anObject); return GetObject(anObject);
} }

View File

@ -51,6 +51,15 @@
#include <TopoDS_Iterator.hxx> #include <TopoDS_Iterator.hxx>
#include "utilities.h" #include "utilities.h"
#include <sys/time.h>
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; using namespace std;
// SALOME // SALOME
@ -254,7 +263,9 @@ vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShap
for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) { for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
START_TIMING
GEOM_Actor* FaceActor = GEOM_Actor::New(); GEOM_Actor* FaceActor = GEOM_Actor::New();
END_TIMING(450)
FaceActor->SetShadingProperty(FaceProp); FaceActor->SetShadingProperty(FaceProp);
FaceActor->SetWireframeProperty(IsoProp); FaceActor->SetWireframeProperty(IsoProp);