5
我试图运行我的代码使用cProfile的性能测试,但可悲的是,无论我如何尝试cProfile拒绝正常运行。 这里就是我所做的:蟒蛇 - c配置文件未运行
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>''
有人可以帮我调试这一点,并希望提供一个解决方案?
我在Wing IDE 101 ver4.1上运行Python 2.7.3。
谢谢!!!
我已经尝试导入pstats,但它仍报告相同的错误。 = [ – turtlesoup
不,我的意思是试着在shell中写入import pstats。只要检查它是否存在,如果存在,那么你是否还有其他错误。如果成功导入,那么您需要查看该模块是否不坏或什么。尝试一下这里提到的一些函数http://docs.python.org/library/profile.html pstats在一个单独的文件中(不在你的主代码中,只是为了检查pstats是否工作正常。) – 2012-07-03 08:45:13