Преглед изворни кода

dev helper: add cumulative option to profiling

Joseph Brandenburg пре 2 недеља
родитељ
комит
cc95126b34
1 измењених фајлова са 7 додато и 2 уклоњено
  1. 7 2
      ops_nodegroup.py

+ 7 - 2
ops_nodegroup.py

@@ -288,27 +288,32 @@ class ExecuteNodeTree(Operator):
             import pstats, io
             from pstats import SortKey
             sortby = SortKey.TIME
+            if 'cum' in environ.get("DOPROFILE").lower():
+                sortby = SortKey.CUMULATIVE
             printme1 = ''
             with cProfile.Profile() as pr:
                 tree.update_tree(context, error_popups = pass_error)
                 # from the Python docs at https://docs.python.org/3/library/profile.html#module-cProfile
                 s1 = io.StringIO()
-                # sortby = SortKey.CUMULATIVE
                 ps1 = pstats.Stats(pr, stream=s1).strip_dirs().sort_stats(sortby)
                 ps1.print_stats(30) # print the top 20
+                # ps1.print_callers("is_signature_in_other_signature")
+                # ps1.print_callees("is_signature_in_other_signature")
                 printme1 += s1.getvalue()
                 printme1 += f"Total profiled time: {ps1.total_tt:.6f} seconds"
             with cProfile.Profile() as pr:
                 tree.execute_tree(context, error_popups = pass_error, profile=True)
                 # from the Python docs at https://docs.python.org/3/library/profile.html#module-cProfile
                 s = io.StringIO()
-                # sortby = SortKey.CUMULATIVE
                 ps = pstats.Stats(pr, stream=s).strip_dirs().sort_stats(sortby)
                 ps.print_stats(30) # print the top 20
+                # ps.print_callers("is_signature_in_other_signature")
+                # ps.print_callees("is_signature_in_other_signature")
                 print (printme1)
                 print(s.getvalue())
                 print(f"Total profiled time: {ps.total_tt:.6f} seconds")
 
+
         else:
             update_failed = tree.update_tree(context, error_popups = pass_error)
             if update_failed: # failed. Cannot execute.