Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

feat(performance_stats): improve function identification in execution time logging

myhloli978ef41cdd9f
diff --git a/magic_pdf/libs/performance_stats.py b/magic_pdf/libs/performance_stats.py
index 0ed8ebc7..3aeaeb33 100644
--- a/magic_pdf/libs/performance_stats.py
+++ b/magic_pdf/libs/performance_stats.py
@@ -48,7 +48,18 @@ def measure_time(func):
start_time = time.time()
result = func(*args, **kwargs)
execution_time = time.time() - start_time
- PerformanceStats.add_execution_time(func.__name__, execution_time)
+
+ # 获取更详细的函数标识
+ if hasattr(func, "__self__"): # 实例方法
+ class_name = func.__self__.__class__.__name__
+ full_name = f"{class_name}.{func.__name__}"
+ elif hasattr(func, "__qualname__"): # 类方法或静态方法
+ full_name = func.__qualname__
+ else:
+ module_name = func.__module__
+ full_name = f"{module_name}.{func.__name__}"
+
+ PerformanceStats.add_execution_time(full_name, execution_time)
return result
return wrapper
\ No newline at end of file