changeset 766:cf4e0f3c2406

Profiling points
author Chris Cannam
date Thu, 14 May 2020 16:38:48 +0100
parents eae885290abc
children 7bded7599874
files framework/Document.cpp framework/MainWindowBase.cpp
diffstat 2 files changed, 39 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/framework/Document.cpp	Thu May 14 16:38:37 2020 +0100
+++ b/framework/Document.cpp	Thu May 14 16:38:48 2020 +0100
@@ -64,6 +64,8 @@
 
 Document::~Document()
 {
+    Profiler profiler("Document::~Document");
+    
     //!!! Document should really own the command history.  atm we
     //still refer to it in various places that don't have access to
     //the document, be nice to fix that
@@ -115,6 +117,8 @@
 Layer *
 Document::createLayer(LayerFactory::LayerType type)
 {
+    Profiler profiler("Document::createLayer");
+    
     Layer *newLayer = LayerFactory::getInstance()->createLayer(type);
     if (!newLayer) return nullptr;
 
@@ -135,6 +139,8 @@
 Layer *
 Document::createMainModelLayer(LayerFactory::LayerType type)
 {
+    Profiler profiler("Document::createMainModelLayer");
+    
     Layer *newLayer = createLayer(type);
     if (!newLayer) return nullptr;
     setModel(newLayer, m_mainModel);
@@ -144,6 +150,8 @@
 Layer *
 Document::createImportedLayer(ModelId modelId)
 {
+    Profiler profiler("Document::createImportedLayer");
+    
     LayerFactory::LayerTypeSet types =
         LayerFactory::getInstance()->getValidLayerTypes(modelId);
 
@@ -180,6 +188,8 @@
 Layer *
 Document::createEmptyLayer(LayerFactory::LayerType type)
 {
+    Profiler profiler("Document::createEmptyLayer");
+    
     if (m_mainModel.isNone()) return nullptr;
 
     auto newModel =
@@ -202,6 +212,8 @@
 Document::createDerivedLayer(LayerFactory::LayerType type,
                              TransformId transform)
 {
+    Profiler profiler("Document::createDerivedLayer (type)");
+    
     Layer *newLayer = createLayer(type);
     if (!newLayer) return nullptr;
 
@@ -216,6 +228,8 @@
 Document::createDerivedLayer(const Transform &transform,
                              const ModelTransformer::Input &input)
 {
+    Profiler profiler("Document::createDerivedLayer (transform)");
+    
     Transforms transforms;
     transforms.push_back(transform);
     vector<Layer *> layers = createDerivedLayers(transforms, input);
@@ -227,6 +241,8 @@
 Document::createDerivedLayers(const Transforms &transforms,
                               const ModelTransformer::Input &input)
 {
+    Profiler profiler("Document::createDerivedLayers");
+    
     QString message;
     vector<ModelId> newModels =
         addDerivedModels(transforms, input, message, nullptr);
@@ -309,6 +325,8 @@
                                    const ModelTransformer::Input &input,
                                    LayerCreationHandler *handler)
 {
+    Profiler profiler("Document::createDerivedLayersAsync");
+    
     QString message;
 
     AdditionalModelConverter *amc = new AdditionalModelConverter(this, handler);
@@ -351,6 +369,8 @@
 Document::createLayersForDerivedModels(vector<ModelId> newModels, 
                                        QStringList names)
 {
+    Profiler profiler("Document::createLayersForDerivedModels");
+    
     vector<Layer *> layers;
     
     for (int i = 0; in_range_for(newModels, i); ++i) {
@@ -400,6 +420,8 @@
 void
 Document::setMainModel(ModelId modelId)
 {
+    Profiler profiler("Document::setMainModel");
+    
     ModelId oldMainModel = m_mainModel;
     m_mainModel = modelId;
     
@@ -583,6 +605,8 @@
                                  const ModelTransformer::Input &input,
                                  ModelId outputModelToAdd)
 {
+    Profiler profiler("Document::addAlreadyDerivedModel");
+    
     if (m_models.find(outputModelToAdd) != m_models.end()) {
         SVCERR << "WARNING: Document::addAlreadyDerivedModel: Model already added"
                << endl;
@@ -620,6 +644,8 @@
 void
 Document::addNonDerivedModel(ModelId modelId)
 {
+    Profiler profiler("Document::addNonDerivedModel");
+    
     if (ModelById::isa<AggregateWaveModel>(modelId)) {
 #ifdef DEBUG_DOCUMENT
         SVCERR << "Document::addNonDerivedModel: Model " << modelId << " is an aggregate model, adding it to aggregates" << endl;
@@ -670,6 +696,8 @@
 void
 Document::addAdditionalModel(ModelId modelId)
 {
+    Profiler profiler("Document::addAdditionalModel");
+    
     if (m_models.find(modelId) != m_models.end()) {
         SVCERR << "WARNING: Document::addAdditionalModel: Model already added"
                << endl;
@@ -706,6 +734,8 @@
                           const ModelTransformer::Input &input,
                           QString &message)
 {
+    Profiler profiler("Document::addDerivedModel");
+    
     for (auto &rec : m_models) {
         if (rec.second.transform == transform &&
             rec.second.source == input.getModel() && 
@@ -728,6 +758,8 @@
                            QString &message,
                            AdditionalModelConverter *amc)
 {
+    Profiler profiler("Document::addDerivedModels");
+    
     vector<ModelId> mm = 
         ModelTransformerFactory::getInstance()->transformMultiple
         (transforms, input, message, amc);
@@ -768,6 +800,8 @@
 void
 Document::releaseModel(ModelId modelId)
 {
+    Profiler profiler("Document::releaseModel");
+    
     // This is called when a layer has been deleted or has replaced
     // its model, in order to reclaim storage for the old model. It
     // could be a no-op without making any functional difference, as
@@ -854,6 +888,8 @@
 void
 Document::deleteLayer(Layer *layer, bool force)
 {
+    Profiler profiler("Document::deleteLayer");
+    
     if (m_layerViewMap.find(layer) != m_layerViewMap.end() &&
         m_layerViewMap[layer].size() > 0) {
 
@@ -914,6 +950,8 @@
 void
 Document::setModel(Layer *layer, ModelId modelId)
 {
+    Profiler profiler("Document::setModel");
+    
     if (!modelId.isNone() && 
         modelId != m_mainModel &&
         m_models.find(modelId) == m_models.end()) {
--- a/framework/MainWindowBase.cpp	Thu May 14 16:38:37 2020 +0100
+++ b/framework/MainWindowBase.cpp	Thu May 14 16:38:48 2020 +0100
@@ -4167,6 +4167,7 @@
 void
 MainWindowBase::layerRemoved(Layer *)
 {
+    Profiler profiler("MainWindowBase::layerRemoved");
 //    SVDEBUG << "MainWindowBase::layerRemoved(" << layer << ")" << endl;
     updateMenuStates();
 }