在任何东西(例如mergeSort)上运行cProfile时,我都会在运行时获取所有000,并且未在过程中列出/测试关键行/ vars /方法。似乎只能根据方法,内部进行测试。请告知。
以下是我的mergeSort结果,我尝试运行 带有-和c / out括号的python -m cProfile [mergeSort(lst)]-在文档中都看到了。 我可以使用的唯一版本是: 导入cProfile cProfile.run(mergeSort(lst))
或所示的enable()disable()方法。
格式化效果不佳,因此附加了图像。 cProfile Results
结果:
''' [17、20、26、31、44、54、55、77、93] 0.000秒内进行127个函数调用(111个原始调用)
订购者:标准名称
ncalls tottime percall cumtime percall filename:lineno(function) 17/1 0.000 0.000 0.000 0.000:1(合并排序) 1 0.000 0.000 0.000 0.000:36() 1 0.000 0.000 0.000 0.000:37() 2 0.000 0.000 0.000 0.000 codeop.py:132(通话) 2 0.000 0.000 0.000 0.000 hooks.py:142(呼叫) 2 0.000 0.000 0.000 0.000钩子.py:207(pre_run_code_hook) 2 0.000 0.000 0.000 0.000 Interactiveshell.py:1104(user_global_ns) 2 0.000 0.000 0.000 0.000 Interactiveshell.py:2933(run_code) 2 0.000 0.000 0.000 0.000 ipstruct.py:125( getattr ) 2 0.000 0.000 0.000 0.000 {内置方法builtins.compile} 2 0.000 0.000 0.000 0.000 {内置方法builtins.exec} 91 0.000 0.000 0.000 0.000 {内置方法builtins.len} 1 0.000 0.000 0.000 0.000 {'_lsprof.Profiler'对象的方法'禁用'}
'''