[Bf-blender-cvs] [725d0be] depsgraph_refactor: Depsgraph Debugging: Rudimentary stats for depsgraph

Joshua Leung noreply at git.blender.org
Thu Dec 18 12:17:52 CET 2014


Commit: 725d0be5d6d2a3d463047e00158e58116ddac475
Author: Joshua Leung
Date:   Fri Dec 19 00:17:37 2014 +1300
Branches: depsgraph_refactor
https://developer.blender.org/rB725d0be5d6d2a3d463047e00158e58116ddac475

Depsgraph Debugging: Rudimentary stats for depsgraph

Added a method/operator which prints out how many operations, relations, and outer nodes
we have in the graph at a time. This is mostly useful to check on the complexity of
rig files (e.g. koro from caminandes).

===================================================================

M	release/scripts/startup/bl_operators/anim.py
M	release/scripts/startup/bl_ui/space_info.py
M	source/blender/depsgraph/DEG_depsgraph_debug.h
M	source/blender/depsgraph/intern/depsgraph_debug.cpp
M	source/blender/makesrna/intern/rna_depsgraph.c

===================================================================

diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py
index b3eace9..264b153 100644
--- a/release/scripts/startup/bl_operators/anim.py
+++ b/release/scripts/startup/bl_operators/anim.py
@@ -368,6 +368,17 @@ class UpdateAnimatedTransformConstraint(Operator):
 
 ######################################
 
+class DEPSGRAPH_OT_stats(Operator):
+    """Report the number of elements in the dependency graph"""
+    bl_idname = "depsgraph.stats"
+    bl_label = "Depsgraph Stats Report"
+    bl_options = {'REGISTER'}
+
+    def execute(self, context):
+        context.scene.depsgraph.debug_stats()
+        return {'FINISHED'}
+
+
 class DEPSGRAPH_OT_rebuild(Operator):
     """Force the dependency graph to be rebuilt to account for modified dependencies"""
     bl_idname = "depsgraph.rebuild"
diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py
index d1c59c9..87d7f41 100644
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@ -52,6 +52,7 @@ class INFO_HT_header(Header):
 
         row = layout.row(align=True)
         row.label(text="Depsgraph:", icon='RADIO')
+        row.operator("depsgraph.stats", text="", icon='INFO')
         row.operator("depsgraph.rebuild", text="", icon='FILE_REFRESH')
         row.operator("depsgraph.export_graphviz", text="Export...", icon='EXPORT').filepath = "graph.dot"
 
diff --git a/source/blender/depsgraph/DEG_depsgraph_debug.h b/source/blender/depsgraph/DEG_depsgraph_debug.h
index a9ed909..0c00f7c 100644
--- a/source/blender/depsgraph/DEG_depsgraph_debug.h
+++ b/source/blender/depsgraph/DEG_depsgraph_debug.h
@@ -76,6 +76,13 @@ void DEG_stats_verify(struct DepsgraphSettings *settings);
 
 struct DepsgraphStatsID *DEG_stats_id(struct ID *id);
 
+/* ------------------------------------------------ */
+
+void DEG_stats_simple(const struct Depsgraph *graph, 
+                      size_t *r_outer,
+                      size_t *r_operations,
+                      size_t *r_relations);
+
 /* ************************************************ */
 /* Graphviz Debugging */
 
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cpp b/source/blender/depsgraph/intern/depsgraph_debug.cpp
index 7904113..c9bafda 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cpp
@@ -902,3 +902,51 @@ bool DEG_debug_compare(const struct Depsgraph *graph1,
 	 */
 	return true;
 }
+
+/* ------------------------------------------------ */
+
+/**
+ * Obtain simple statistics about the complexity of the depsgraph
+ * \param[out] r_outer       The number of outer nodes in the graph
+ * \param[out] r_operations  The number of operation nodes in the graph
+ * \param[out] r_relations   The number of relations between (executable) nodes in the graph
+ */
+void DEG_stats_simple(const Depsgraph *graph, size_t *r_outer,
+                      size_t *r_operations, size_t *r_relations)
+{
+	/* number of operations */
+	if (r_operations) {
+		/* All operations should be in this list, allowing us to count the total number of nodes */
+		*r_operations = graph->operations.size();
+	}
+	
+	/* count number of outer nodes and/or relations between these */
+	if (r_outer || r_relations) {
+		size_t tot_outer = 0;
+		size_t tot_rels = 0;
+		
+		for (Depsgraph::IDNodeMap::const_iterator it = graph->id_hash.begin(); it != graph->id_hash.end(); ++it) {
+			IDDepsNode *id_node = it->second;
+			tot_outer++;
+			
+			for (IDDepsNode::ComponentMap::const_iterator it = id_node->components.begin(); it != id_node->components.end(); ++it) {
+				ComponentDepsNode *comp_node = it->second;
+				tot_outer++;
+				
+				for (ComponentDepsNode::OperationMap::const_iterator it = comp_node->operations.begin(); it != comp_node->operations.end(); ++it) {
+					OperationDepsNode *op_node = it->second;
+					tot_rels += op_node->inlinks.size();
+				}
+			}
+		}
+
+		TimeSourceDepsNode *time_source = graph->find_time_source(NULL);
+		if (time_source != NULL) {
+			tot_rels += time_source->inlinks.size();
+		}
+		
+		if (r_relations) *r_relations = tot_rels;
+		if (r_outer)     *r_outer     = tot_outer;
+	}
+}
+
diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c
index eb10758..66d59b6 100644
--- a/source/blender/makesrna/intern/rna_depsgraph.c
+++ b/source/blender/makesrna/intern/rna_depsgraph.c
@@ -40,6 +40,8 @@
 
 #ifdef RNA_RUNTIME
 
+#include "BKE_report.h"
+
 #include "DEG_depsgraph_debug.h"
 
 static void rna_Depsgraph_debug_graphviz(Depsgraph *graph, const char *filename)
@@ -61,6 +63,20 @@ static void rna_Depsgraph_debug_rebuild(Depsgraph *UNUSED(graph), Main *bmain)
 		DAG_scene_relations_rebuild(bmain, sce);
 }
 
+static void rna_Depsgraph_debug_stats(Depsgraph *graph, ReportList *reports)
+{
+	size_t outer, ops, rels;
+	
+	DEG_stats_simple(graph, &outer, &ops, &rels);
+	
+	// XXX: report doesn't seem to work
+	printf("Approx %u Operations, %u Relations, %u Outer Nodes\n",
+	       ops, rels, outer);
+		   
+	BKE_reportf(reports, RPT_WARNING, "Approx. %u Operations, %u Relations, %u Outer Nodes",
+	            ops, rels, outer);
+}
+
 #else
 
 static void rna_def_depsgraph(BlenderRNA *brna)
@@ -80,6 +96,10 @@ static void rna_def_depsgraph(BlenderRNA *brna)
 	func = RNA_def_function(srna, "debug_rebuild", "rna_Depsgraph_debug_rebuild");
 	RNA_def_function_flag(func, FUNC_USE_MAIN);
 	RNA_def_property_flag(parm, PROP_REQUIRED);
+	
+	func = RNA_def_function(srna, "debug_stats", "rna_Depsgraph_debug_stats");
+	RNA_def_function_ui_description(func, "Report the number of elements in the Dependency Graph");
+	RNA_def_function_flag(func, FUNC_USE_REPORTS);
 }
 
 void RNA_def_depsgraph(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list