# 开启轻量函数耗时统计

enable_profile(func_list=None)
get_profile_stats()
1
2

该能力只统计 runner 调用的策略生命周期函数和调度函数,不做 C++ 内部性能分析。

参数和返回:

API 说明
enable_profile() 统计全部被 runner 调用的用户函数
enable_profile(["handle_bar", "trade"]) 只统计指定函数名
get_profile_stats() 返回当前进程内统计快照
BacktestResult.profile_stats 回测结束后的统计结果
profile_stats.csv 指定 output_dir 时额外导出的统计文件