Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
6f914fb7
"tools/git@developer.sourcefind.cn:wangsen/paddle_dbnet.git" did not exist on "8f7eb08651d2699b9a1aeb3b0b260d0bb12a4ee5"
Commit
6f914fb7
authored
Jul 13, 2023
by
comfyanonymous
Browse files
Print prestartup times for custom nodes.
parent
3bc8be33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
12 deletions
+24
-12
main.py
main.py
+24
-12
No files found.
main.py
View file @
6f914fb7
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():
...
@@ -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
(
"
\n
Prestartup 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
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment