From: Christophe Bourcier Date: Tue, 24 Oct 2023 09:02:50 +0000 (+0200) Subject: Print some compute times for exportXAO (and similar functions) and loadModifiedShapes. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fcbr%2Fprofile_exportXAO_and_loadModifiedShapes;p=modules%2Fshaper.git Print some compute times for exportXAO (and similar functions) and loadModifiedShapes. More info in bos #38090 and bos #38359 --- diff --git a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py index c9fa8c715..c76fd0d13 100644 --- a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py +++ b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py @@ -32,6 +32,8 @@ from salome.shaper import model import SHAPERSTUDY_ORB import SHAPERSTUDY_utils +import time + ## @ingroup Plugins # Feature to export all shapes and groups into the GEOM module class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): @@ -60,6 +62,8 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): ## Exports all shapes and groups into the GEOM module. def execute(self): + print("PublishToStudy execute start") + t0=time.time() aSession = ModelAPI.ModelAPI_Session.get() aPartSet = aSession.moduleDocument() # check that the PartSet document current feature is the last to avoid problems with all @@ -159,6 +163,9 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): aDeadGroupEntry = "dead0" + str(anIndex) + "_" + aGroup.GetEntry() aGroup.SetEntry(aDeadGroupEntry) + t1=time.time() + print("PublishToStudy execute took %.3f s"%(t1-t0)) + # Part of the "execute" method: processes the Groups of theRes result publication. # If theFields is true, the same is performed for Fields. def processGroups(self, theRes, theEngine, thePartFeatureId, theStudyShape, theFields): @@ -169,6 +176,7 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): else: allRefGroups.append(ModelAPI.referencedFeatures(theRes, "Group", True)) allRefGroups.append(ModelAPI.referencedFeatures(theRes, "Shared_faces", True)) + for aRefGroups in allRefGroups: for aRef in aRefGroups: aGroupIndices = [] @@ -182,12 +190,17 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): for aGroupRes in aRef.results(): aShape = aGroupRes.shape() anExplorer = GeomAPI_ShapeExplorer(aShape, aSelType) + + print("loop on GeomAlgoAPI_CompoundBuilder::id start for group", aGroupRes.data().name()) + t1=time.time() while anExplorer.more(): anId = GeomAlgoAPI.GeomAlgoAPI_CompoundBuilder.id(aResShape, anExplorer.current()) if anId > 0 and not anId in aGroupHasIndex: aGroupIndices.append(anId) aGroupHasIndex[anId] = 0 anExplorer.next() + t2=time.time() + print("loop on GeomAlgoAPI_CompoundBuilder::id took %.3f s"%(t2-t1)) if len(aGroupIndices): # create group aGroupFeatureId = aRef.data().featureId() if theFields: diff --git a/src/ExchangeAPI/ExchangeAPI_Export.cpp b/src/ExchangeAPI/ExchangeAPI_Export.cpp index 6390b6d97..b220760ee 100644 --- a/src/ExchangeAPI/ExchangeAPI_Export.cpp +++ b/src/ExchangeAPI/ExchangeAPI_Export.cpp @@ -294,6 +294,7 @@ ExportPtr exportToFile(const std::shared_ptr & thePart, const std::list & theSelectionList, const std::string & theFileFormat) { + std::cout << "exportToFile " << theFileFormat << std::endl; apply(); // finish previous operation to make sure all previous operations are done std::shared_ptr aFeature = thePart->addFeature(ExchangePlugin_ExportFeature::ID()); @@ -305,6 +306,7 @@ ExportPtr exportToXAO(const std::shared_ptr & thePart, const std::string & theAuthor, const std::string & theGeometryName) { + std::cout << "exportToXAO " << std::endl; apply(); // finish previous operation to make sure all previous operations are done std::shared_ptr aFeature = thePart->addFeature(ExchangePlugin_ExportFeature::ID()); @@ -338,6 +340,7 @@ ExportPtr exportToXAO(const std::shared_ptr & thePart, const std::string & /*theAuthor*/, const std::string & /*theGeometryName*/) { + std::cout << "exportToXAO with selected shape" << std::endl; apply(); // finish previous operation to make sure all previous operations are done std::shared_ptr aFeature = thePart->addFeature(ExchangePlugin_ExportFeature::ID()); @@ -350,6 +353,7 @@ PyObject* exportToXAOMem(const std::shared_ptr & thePart, const std::string & theAuthor, const std::string & theGeometryName) { + std::cout << "exportToXAOMem with selected shape" << std::endl; apply(); // finish previous operation to make sure all previous operations are done std::shared_ptr aFeature = thePart->addFeature(ExchangePlugin_ExportFeature::ID()); diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index ca1a2e4dd..2d46b9e39 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -70,6 +70,8 @@ #include #include +#include +#include ExchangePlugin_ExportFeature::ExchangePlugin_ExportFeature() { @@ -207,6 +209,13 @@ void ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName, } } + std::string msg; + if (isMemoryExport) + msg = "to memory"; + else + msg = "to file"; + std::cout << "ExchangePlugin_ExportFeature::exportFile " << aFormatName << " " << msg << std::endl; + if (aFormatName == "XAO") { exportXAO(theFileName, isMemoryExport); return; @@ -329,6 +338,9 @@ void ExchangePlugin_ExportFeature::exportSTL(const std::string& theFileName) void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName, const bool isMemoryExport) { + std::cout << "ExchangePlugin_ExportFeature::exportXAO start" << std::endl; + std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); + try { std::string anError; @@ -430,7 +442,8 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName, if (aDocuments.empty()) aDocuments.push_back(document()); std::list::iterator aDoc = aDocuments.begin(); - for(; aDoc != aDocuments.end(); aDoc++) { + int i=0; + for(; aDoc != aDocuments.end(); aDoc++, i++) { // groups int aGroupCount = (*aDoc)->size(ModelAPI_ResultGroup::group()); for (int aGroupIndex = 0; aGroupIndex < aGroupCount; ++aGroupIndex) { @@ -458,6 +471,10 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName, XAO::Group* aXaoGroup = aXao.addGroup(aGroupDimension, Locale::Convert::toString(aResultGroup->data()->name())); + std::cout << "loop on GeomAlgoAPI_CompoundBuilder::id start for doc " << i ; + std::cout << " and group " << Locale::Convert::toString(aResultGroup->data()->name()) << std::endl; + std::chrono::steady_clock::time_point start2 = std::chrono::steady_clock::now(); + try { GeomAPI_ShapeExplorer aGroupResExplorer(aResultGroup->shape(), aSelType); for(; aGroupResExplorer.more(); aGroupResExplorer.next()) { @@ -484,6 +501,10 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName, aXao.removeGroup(aXaoGroup); // LCOV_EXCL_STOP } + + std::chrono::steady_clock::time_point end2 = std::chrono::steady_clock::now(); + std::cout << "loop on GeomAlgoAPI_CompoundBuilder::id took " + << std::chrono::duration_cast(end2 - start2).count()*1e-6 << " seconds" << std::endl; } // fields @@ -606,6 +627,10 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName, return; } // LCOV_EXCL_STOP + + std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); + std::cout << "ExchangePlugin_ExportFeature::exportXAO took " + << std::chrono::duration_cast(end - start).count()*1e-6 << " seconds" << std::endl; } bool ExchangePlugin_ExportFeature::isMacro() const diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index eaea11a1a..8c23ef11e 100644 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -58,6 +58,7 @@ #include #include #include +#include // DEB //#include //#define DEB_IMPORT 1 @@ -624,6 +625,8 @@ void Model_BodyBuilder::loadModifiedShapes(const GeomMakeShapePtr& theAlgo, const GeomAPI_Shape::ShapeType theShapeTypeToExplore, const std::string& theName) { +// std::cout << "Model_BodyBuilder::loadModifiedShapes start" << std::endl; +// std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); GeomShapePtr aResultShape = shape(); GeomShapePtr aShapeToExplore = theOldShape; if (theAlgo->isNewShapesCollected(theOldShape, theShapeTypeToExplore)) { @@ -687,6 +690,9 @@ void Model_BodyBuilder::loadModifiedShapes(const GeomMakeShapePtr& theAlgo, storeExternalReference(anOriginalLabel, aBuilder->NamedShape()->Label()); } } +// std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); +// std::cout << "Model_BodyBuilder::loadModifiedShapes took " +// << std::chrono::duration_cast(end - start).count()*1e-6 << " seconds" << std::endl; } void Model_BodyBuilder::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo, diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index 45bcad650..878d832ca 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #define RECURSE_TOP_LEVEL 50 @@ -208,6 +209,8 @@ void loadModifiedShapes(ResultBodyPtr theResultBody, const GeomShapePtr theResultShape, const std::string& theNamePrefix) { + std::cout << "ModelAPI_Tools::loadModifiedShapes start" << std::endl; + std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); theResultBody->storeModified(theBaseShapes, theResultShape, theMakeShape); ListOfShape aShapes = theBaseShapes; @@ -221,6 +224,9 @@ void loadModifiedShapes(ResultBodyPtr theResultBody, theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE, theNamePrefix); theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE, theNamePrefix); } + std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); + std::cout << "ModelAPI_Tools::loadModifiedShapes took " + << std::chrono::duration_cast(end - start).count()*1e-6 << " seconds" << std::endl; } //==================================================================================================