-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path__init__.py
98 lines (73 loc) · 3.25 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
bl_info = {
"name" : "Plugin-Profiler",
"author" : "bd3d",
"description" : "Benchmark or Debug Python Plugins",
"blender" : (3, 0, 0),
"version" : (1, 0, 0),
"wiki_url" : "https://blender.stackexchange.com/questions/273803/profiling-a-blender-plugin/274271#274271",
"tracker_url" : "https://blender.stackexchange.com/questions/273803/profiling-a-blender-plugin/274271#274271",
"category" : "Development",
}
from . exectracker import PLUGINPROFILER_OT_exectracker
from . benchmarker import PLUGINPROFILER_OT_benchmarker
from . benchmarker import PLUGINPROFILER_OT_benchmarkops
from . interface import PLUGINPROFILER_UL_name_list1
from . interface import PLUGINPROFILER_UL_name_list2
from . interface import PLUGINPROFILER_UL_name_list3
from . interface import PLUGINPROFILER_UL_name_list4
from . interface import PLUGINPROFILER_OT_uilist_actions
from . presetting import PLUGINPROFILER_OT_add_trackerpreset
from . presetting import PLUGINPROFILER_OT_load_trackerpreset
from . presetting import PLUGINPROFILER_OT_remove_trackerpreset
from . presetting import PLUGINPROFILER_PT_trackerpreset_panel
from . property import PLUGINPROFILER_PR_exectracker_modules_ignore
from . property import PLUGINPROFILER_PR_exectracker_modules_only
from . property import PLUGINPROFILER_PR_exectracker_functions_ignore
from . property import PLUGINPROFILER_PR_exectracker_functions_only
from . property import PLUGINPROFILER_AddonPref
from . property import PLUGINPROFILER_PR_Window
classes = (
PLUGINPROFILER_OT_exectracker,
PLUGINPROFILER_OT_benchmarker,
PLUGINPROFILER_OT_benchmarkops,
PLUGINPROFILER_UL_name_list1,
PLUGINPROFILER_UL_name_list2,
PLUGINPROFILER_UL_name_list3,
PLUGINPROFILER_UL_name_list4,
PLUGINPROFILER_OT_uilist_actions,
PLUGINPROFILER_OT_add_trackerpreset,
PLUGINPROFILER_OT_load_trackerpreset,
PLUGINPROFILER_OT_remove_trackerpreset,
PLUGINPROFILER_PT_trackerpreset_panel,
PLUGINPROFILER_PR_exectracker_modules_ignore,
PLUGINPROFILER_PR_exectracker_modules_only,
PLUGINPROFILER_PR_exectracker_functions_ignore,
PLUGINPROFILER_PR_exectracker_functions_only,
PLUGINPROFILER_AddonPref,
PLUGINPROFILER_PR_Window,
)
import bpy
def cleanse_modules():
"""remove all plugin modules from sys.modules, will load them again, creating an effective hit-reload soluton
Not sure why blender is no doing this already whe disabling a plugin..."""
#https://devtalk.blender.org/t/plugin-hot-reload-by-cleaning-sys-modules/20040
import sys
all_modules = sys.modules
all_modules = dict(sorted(all_modules.items(),key= lambda x:x[0])) #sort them
for k,v in all_modules.items():
if k.startswith(__name__):
del sys.modules[k]
return None
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.WindowManager.plugin_profiler = bpy.props.PointerProperty(type=PLUGINPROFILER_PR_Window)
return None
def unregister():
del bpy.types.WindowManager.plugin_profiler
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
cleanse_modules()
return None
if (__name__=="__main__"):
pass