]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Print some compute times for exportXAO (and similar functions) and loadModifiedShapes. cbr/profile_exportXAO_and_loadModifiedShapes
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Tue, 24 Oct 2023 09:02:50 +0000 (11:02 +0200)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Tue, 24 Oct 2023 09:02:50 +0000 (11:02 +0200)
More info in bos #38090 and bos #38359

src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py
src/ExchangeAPI/ExchangeAPI_Export.cpp
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp
src/Model/Model_BodyBuilder.cpp
src/ModelAPI/ModelAPI_Tools.cpp

index c9fa8c7158bc94bf38d28779cfda9b203e0a68f0..c76fd0d13182617f44000ad94c6cdc99ef3676b8 100644 (file)
@@ -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:
index 6390b6d973a78fa5815a9c8c3bba5fa5716c2cfd..b220760ee68a3f75eddc70285d692543257cab54 100644 (file)
@@ -294,6 +294,7 @@ ExportPtr exportToFile(const std::shared_ptr<ModelAPI_Document> & thePart,
                   const std::list<ModelHighAPI_Selection> & 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<ModelAPI_Feature> aFeature =
     thePart->addFeature(ExchangePlugin_ExportFeature::ID());
@@ -305,6 +306,7 @@ ExportPtr exportToXAO(const std::shared_ptr<ModelAPI_Document> & 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<ModelAPI_Feature> aFeature =
     thePart->addFeature(ExchangePlugin_ExportFeature::ID());
@@ -338,6 +340,7 @@ ExportPtr exportToXAO(const std::shared_ptr<ModelAPI_Document> & 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<ModelAPI_Feature> aFeature =
     thePart->addFeature(ExchangePlugin_ExportFeature::ID());
@@ -350,6 +353,7 @@ PyObject* exportToXAOMem(const std::shared_ptr<ModelAPI_Document> & 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<ModelAPI_Feature> aFeature =
     thePart->addFeature(ExchangePlugin_ExportFeature::ID());
index ca1a2e4ddba94afc986940d977035c6a824ad269..2d46b9e394b66c49b7d6b111ed9a33b365859a8b 100644 (file)
@@ -70,6 +70,8 @@
 #include <XAO_Geometry.hxx>
 
 #include <ExchangePlugin_Tools.h>
+#include <chrono>
+#include <iostream>
 
 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<DocumentPtr>::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<std::chrono::microseconds>(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<std::chrono::microseconds>(end - start).count()*1e-6 << " seconds" << std::endl;
 }
 
 bool ExchangePlugin_ExportFeature::isMacro() const
index eaea11a1a80681c24452313d3471ee3ebb7d2f6e..8c23ef11eb0412404e09365d86c9070fae40673f 100644 (file)
@@ -58,6 +58,7 @@
 #include <GeomAlgoAPI_MakeShape.h>
 #include <GeomAlgoAPI_SortListOfShapes.h>
 #include <Config_PropManager.h>
+#include <chrono>
 // DEB
 //#include <TCollection_AsciiString.hxx>
 //#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<std::chrono::microseconds>(end - start).count()*1e-6 << " seconds" << std::endl;
 }
 
 void Model_BodyBuilder::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
index 45bcad650cd1f1a13fc5f821ebd07337878d8385..878d832ca921ab8a189d5ec1e2febde16cf5b142 100644 (file)
@@ -52,6 +52,7 @@
 #include <sstream>
 #include <vector>
 #include <array>
+#include <chrono>
 
 #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<std::chrono::microseconds>(end - start).count()*1e-6 << " seconds" << std::endl;
 }
 
 //==================================================================================================