hutool.core.prof¶
性能分析工具类,提供基于 cProfile 的函数和代码块性能分析。
Module Contents¶
Classes¶
性能分析工具类,提供 cProfile 装饰器和上下文管理器。 |
API¶
- class hutool.core.prof.ProfUtil¶
性能分析工具类,提供 cProfile 装饰器和上下文管理器。
所有分析结果会打印到标准输出。
- static profile_context(sort_by: str = 'cumtime', limit: int = 10)¶
上下文管理器:对代码块进行 cProfile 性能分析。
Examples:
with ProfUtil.profile_context(sort_by="tottime", limit=5): # ... 需要分析的代码 ... pass
- 参数:
sort_by – 排序字段,默认
"cumtime"limit – 打印行数,默认 10
- static prof_context(sort_by: str = 'cumtime', limit: int = 10)¶
profile_context别名。- 参数:
sort_by – 排序字段,默认
"cumtime"limit – 打印行数,默认 10