.net 启用调试时外部模块的IronPython性能不佳
在尝试导入和使用Symphy时,我在VS2010内部遇到了一些IronPython性能问题 我有一个IronPython测试项目,其中包含以下代码:.net 启用调试时外部模块的IronPython性能不佳,.net,performance,ironpython,ironpython-studio,.net,Performance,Ironpython,Ironpython Studio,在尝试导入和使用Symphy时,我在VS2010内部遇到了一些IronPython性能问题 我有一个IronPython测试项目,其中包含以下代码: import time print 'StandaloneIronPython' startTime = time.time() from sympy import * importTime = time.time() - startTime print 'Import time = %f' % importTime startTime =
import time
print 'StandaloneIronPython'
startTime = time.time()
from sympy import *
importTime = time.time() - startTime
print 'Import time = %f' % importTime
startTime = time.time()
for x in (x/10.0 for x in xrange(-100,100)):
(x**2-2*x)
numericsTime = time.time() - startTime
print 'Basic numerics time= %f' % numericsTime
startTime = time.time()
for x in (x/10.0 for x in xrange(-100,100)):
N(x**2-2*x)
sympyTime = time.time() - startTime
print 'SymPy time = %f' % sympyTime
raw_input('Press enter to continue...')
下载并安装为一个egg;我的“IronPython 2.7\Lib\site packages”文件夹位于项目搜索路径中
如果我通过“调试>开始调试”运行程序,我会大致得到以下结果:
StandaloneIronPython
Import time = 12.090019
Basic numerics time= 0.015594
SymPy time = 2.230804
Press enter to continue...
但是,如果我通过“调试>启动而不调试”运行程序,我会得到大约:
StandaloneIronPython
Import time = 2.199600
Basic numerics time= 0.015602
SymPy time = 0.140404
Press enter to continue...
我获得了~5倍的导入速度和>10倍的运行速度
那么,如果IronPython花费所有时间调试库代码,我如何从中获得良好的性能呢
- 有没有一种方法可以将Symphy打包为库、程序集或其他一些可以快速执行的东西
- 有没有办法告诉VS2010不要调试Symphy的代码
- 还有其他解决办法吗
如果这确实是你的问题,不幸的是没有一个好的解决办法。将Python代码预编译为.dll不会阻止抛出这些异常。选中“公共语言运行时异常”旁边的“抛出”框,然后选择“调试>开始调试”不会在任何异常时停止。Hm,我能想到的另一件事是,调试器正在禁用Symphy依赖于执行的JIT优化。尝试进入工具>选项>调试并取消选中“在模块加载时抑制JIT优化”选项。