如果是普通的flask页面profile建议使用WSGI Application Profiler
它会自动分析每一个页面,并profile,内部也是cprofile实现。
针对初始化过程只能手动使用cProfile:
python -m cProfile -o profiling run_web.py
等到初始化完毕再进入python ide:
>>> import pstats
>>> stats = pstats.Stats('profiling')
>>> stats.sort_stats('time').print_stats(10)