mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-03-12 22:02:14 +00:00
Print prestartup times for custom nodes.
This commit is contained in:
parent
3bc8be33e4
commit
6f914fb77d
36
main.py
36
main.py
@ -1,22 +1,24 @@
|
|||||||
import os
|
import os
|
||||||
import importlib.util
|
import importlib.util
|
||||||
import folder_paths
|
import folder_paths
|
||||||
|
import time
|
||||||
|
|
||||||
def execute_prestartup_script():
|
def execute_prestartup_script():
|
||||||
def execute_script(script_path):
|
def execute_script(script_path):
|
||||||
if os.path.exists(script_path):
|
module_name = os.path.splitext(script_path)[0]
|
||||||
module_name = os.path.splitext(script_path)[0]
|
try:
|
||||||
try:
|
spec = importlib.util.spec_from_file_location(module_name, script_path)
|
||||||
spec = importlib.util.spec_from_file_location(module_name, script_path)
|
module = importlib.util.module_from_spec(spec)
|
||||||
module = importlib.util.module_from_spec(spec)
|
spec.loader.exec_module(module)
|
||||||
spec.loader.exec_module(module)
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to execute startup-script: {script_path} / {e}")
|
print(f"Failed to execute startup-script: {script_path} / {e}")
|
||||||
|
return False
|
||||||
|
|
||||||
node_paths = folder_paths.get_folder_paths("custom_nodes")
|
node_paths = folder_paths.get_folder_paths("custom_nodes")
|
||||||
for custom_node_path in node_paths:
|
for custom_node_path in node_paths:
|
||||||
possible_modules = os.listdir(custom_node_path)
|
possible_modules = os.listdir(custom_node_path)
|
||||||
|
node_prestartup_times = []
|
||||||
|
|
||||||
for possible_module in possible_modules:
|
for possible_module in possible_modules:
|
||||||
module_path = os.path.join(custom_node_path, possible_module)
|
module_path = os.path.join(custom_node_path, possible_module)
|
||||||
@ -24,8 +26,19 @@ def execute_prestartup_script():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
script_path = os.path.join(module_path, "prestartup_script.py")
|
script_path = os.path.join(module_path, "prestartup_script.py")
|
||||||
execute_script(script_path)
|
if os.path.exists(script_path):
|
||||||
|
time_before = time.perf_counter()
|
||||||
|
success = execute_script(script_path)
|
||||||
|
node_prestartup_times.append((time.perf_counter() - time_before, module_path, success))
|
||||||
|
if len(node_prestartup_times) > 0:
|
||||||
|
print("\nPrestartup times for custom nodes:")
|
||||||
|
for n in sorted(node_prestartup_times):
|
||||||
|
if n[2]:
|
||||||
|
import_message = ""
|
||||||
|
else:
|
||||||
|
import_message = " (PRESTARTUP FAILED)"
|
||||||
|
print("{:6.1f} seconds{}:".format(n[0], import_message), n[1])
|
||||||
|
print()
|
||||||
|
|
||||||
execute_prestartup_script()
|
execute_prestartup_script()
|
||||||
|
|
||||||
@ -36,7 +49,6 @@ import itertools
|
|||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
import gc
|
import gc
|
||||||
import time
|
|
||||||
|
|
||||||
from comfy.cli_args import args
|
from comfy.cli_args import args
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
|
Loading…
Reference in New Issue
Block a user