我尝试使用cProfile对我的代码进行性能测试,但不幸的是,无论我如何尝试,cProfile都无法正常运行。
以下是我所做的:
import cProfile
cProfile.run('addNum()') # addNum() is a very simple function that adds a bunch of
# numbers into a dictionary
这是我得到的结果:
Traceback (most recent call last):
File "C:\Program Files\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 1, in <module>
# Used internally for debug sandbox under external interpreter
File "C:\Python27\Lib\cProfile.py", line 36, in run
result = prof.print_stats(sort)
File "C:\Python27\Lib\cProfile.py", line 81, in print_stats
pstats.Stats(self).strip_dirs().sort_stats(sort).print_stats()
File "C:\Python27\Lib\pstats.py", line 81, in __init__
self.init(arg)
File "C:\Python27\Lib\pstats.py", line 95, in init
self.load_stats(arg)
File "C:\Python27\Lib\pstats.py", line 124, in load_stats
self.__class__, arg)
TypeError: Cannot create or construct a <class pstats.Stats at 0x01AE9CA8> object from '<cProfile.Profile object at 0x01ACC470>''
有人能帮我调试一下吗,最好能提供解决方案?
我正在运行Python 2.7.3,并使用Wing IDE 101 ver4.1。
谢谢!