This adds profiling of ComfyUI's execution. Disabled by default. commit eb8abf35ac0b0fd5e04781ca7bb0c4af923052e0 Author: ryanontheinstide <ryanfosdick87@gmail.com> Date: Sun Jan 26 13:31:53 2025 -0500 Readme, disable by default commit 32696f9c0742b3f845ac361861a8035ada684ca7 Author: ryanontheinstide <ryanfosdick87@gmail.com> Date: Sun Jan 26 13:01:35 2025 -0500 track more methods commit b6e5912969467986c2736123a0ba249c52a36d09 Author: ryanontheinstide <ryanfosdick87@gmail.com> Date: Sun Jan 26 12:32:34 2025 -0500 working basic execution
65 lines
2.3 KiB
Python
65 lines
2.3 KiB
Python
"""Profiler extension for ComfyUI"""
|
|
import os
|
|
import logging
|
|
|
|
# Configure logging before imports
|
|
logger = logging.getLogger('ComfyUI-ProfilerX')
|
|
logger.setLevel(logging.ERROR) # Set to DEBUG level for maximum info
|
|
|
|
# Add console handler if not already added
|
|
if not logger.handlers:
|
|
ch = logging.StreamHandler()
|
|
ch.setLevel(logging.DEBUG) # Also set handler to DEBUG
|
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
ch.setFormatter(formatter)
|
|
logger.addHandler(ch)
|
|
|
|
logger.info("Initializing ComfyUI-ProfilerX...")
|
|
|
|
from .prestartup import inject_profiling, PROFILER_ENABLED, inject_tracking # Import but don't auto-inject
|
|
from . import server # Register API routes
|
|
from .execution_core import ExecutionTracker
|
|
|
|
# Set up web directory
|
|
WEB_DIRECTORY = "./web"
|
|
|
|
# Try to inject profiling hooks
|
|
profiler_enabled = inject_profiling()
|
|
if not profiler_enabled:
|
|
# If injection fails, remove the profiler node from available nodes
|
|
logger.warning("Disabling profiler nodes due to initialization failure")
|
|
NODE_CLASS_MAPPINGS = {}
|
|
NODE_DISPLAY_NAME_MAPPINGS = {}
|
|
else:
|
|
logger.info("ProfilerX initialization complete - profiler is enabled")
|
|
# Add empty mappings to satisfy ComfyUI's import check
|
|
NODE_CLASS_MAPPINGS = {
|
|
"ProfilerX": type("ProfilerX", (), {
|
|
"CATEGORY": "profiling",
|
|
"RETURN_TYPES": tuple(),
|
|
"FUNCTION": "noop",
|
|
"OUTPUT_NODE": True,
|
|
"INPUT_TYPES": lambda: {"required": {}}
|
|
})
|
|
}
|
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
|
"ProfilerX": "ProfilerX"
|
|
}
|
|
|
|
# Try to inject execution tracking hooks
|
|
execution_tracking_enabled = inject_tracking() if ExecutionTracker.ENABLED else False
|
|
if execution_tracking_enabled:
|
|
logger.info("Execution tracking is enabled")
|
|
else:
|
|
logger.warning("Execution tracking is disabled")
|
|
|
|
def setup_js():
|
|
"""Register web extension with profiler status"""
|
|
logger.debug(f"Setting up web extension (profiler_enabled={PROFILER_ENABLED}, execution_tracking_enabled={execution_tracking_enabled})")
|
|
return {
|
|
"name": "ComfyUI-ProfilerX",
|
|
"module": "index.js",
|
|
"enabled": PROFILER_ENABLED,
|
|
"status": "active" if PROFILER_ENABLED else "disabled",
|
|
"execution_tracking": execution_tracking_enabled
|
|
} |