CodePlexProject Hosting for Open Source Software
Hi,
The difference in speed between debugging and running from the command line seems to be pretty big when using Suds (a soap library for python). Creating a soap client (e.g. 'client=Client(url_of_wsdl)') is almost instantaneous when run from the command line,
but takes about 50 seconds when running from within Visual Studio.
I understand that debugging will always be somewhat slower than running from the command line, but the difference is quite large here. I also tried to run the same code from within NetBeans 7.0.1, this takes about 3 seconds, which is perfectly acceptable.
Is there anything I can do to speed up VS?
Best regards, Berend Veldkamp
If you open the Exceptions dialog (found under the Debug menu) and uncheck the topmost Python exceptions item you may see some improvement.
Typically, slow code under debugging is the result of lots of exceptions being thrown and handled. Because we want to break on an unhandled exception before the stack unwinds, we analyse the source files to determine (make a pretty good guess)
if there is a handler for it (if we let Python unwind until we're certain that there are no handlers, we've already lost the stack frame and local variables where the exception was caused).
An alternative is running without debugging (Ctrl+F5), but in this case you don't get breakpoints or the other debugging features.
Out of interest, is Suds installed in your site-packages directory? We may be able to provide an option to assume exceptions thrown inside Python\Lib are handled (at least until they reappear at user code).
Zooba,
Thanks for your fast reply.
None of the Python exceptions is checked, so I don't think that's the problem.
Ctrl+F5 is an option, but that kind of defeats the purpose of using VS in the first place.
I simply installed Suds with the Python setup tools; the egg is installed in the site-packages folder.
bveldkamp wrote:
None of the Python exceptions is checked, so I don't think that's the problem.
Even the 'User-unhandled' column? If that's unchecked we shouldn't be doing anything to slow down debugging, at least if the cause is lots of exceptions.
So that column was missing ()... After resetting it, I see that all Python exceptions have User-unhandled checked, but they are also disabled, so I cannot uncheck them.
Thanks for your patience.
This sounds like some sort of configuration issue, which a reinstall (maybe just of Python Tools, possibly of VS) may fix, but I'd prefer to solve it than just fall back on that :)
Do you know which set of settings you selected on the first run (General Developer, C++ Developer, etc.)? (If you don't, does your New Project dialog have an "Other Languages" category, and if so, which language isn't in there?) The
Just-My-Code setting is off by default if you select C++ settings, but once it's turned on it all works fine (for me, at least).
Can I clarify whether all Python exceptions have User-unhandled checked? There should be five that aren't (AttributeError, GeneratorExit, IndexError, KeyError and StopIteration).
Could you also check that the Software\Microsoft\VisualStudio\10.0_Config\AD7Metrics\Exception\{EC1375B7-E2CE-43E8-BF75-DC638DE1F1F9}\Python Exceptions\State registry value (probably in HKEY_LOCAL_MACHINE, but maybe CURRENT_USER, depending on how you
installed it) is 0x4020? Here's a cmd.exe copy-paste for you:
reg query "HKLM\Software\Microsoft\VisualStudio\10.0_Config\AD7Metrics\Exception\{EC1375B7-E2CE-43E8-BF75-DC638DE1F1F9}\Python Exceptions" /v Statereg query "HKCU\Software\Microsoft\VisualStudio\10.0_Config\AD7Metrics\Exception\{EC1375B7-E2CE-43E8-BF75-DC638DE1F1F9}\Python Exceptions" /v State
Assuming all that checks out, we'll probably need to grab some more info about your configuration - John should have a script that can help with that. Meanwhile I'll install suds and see if I can reproduce the perf issues.
Actually, here's a simpler question: do you have PTVS 1.0 final installed? I can reproduce everything perfectly with beta 2, including the User-unhandled column being completely disabled.
The performance issue was known with beta 2 and was fixed for RC1, and breaking on user-unhandled exceptions wasn't added until a later version.
The easiest way to check the version is through the Programs and Features dialog. If the product version starts with anything other than "1.0" (beta 2 was 0.8.40406.0, for example), hit uninstall and
blame whoever did the uploading for not putting the version in the filename vote for this issue:.
I fixed it by installing the latest version of PTVS. I had checked the version earlier, but I only looked at Help|About in VS, which claimed 1.0, so I thought I was on the latest version already. The Add/Remove Programs dialog showed 0.8.40406.0.
Thanks again for your fast support.
from scipy import constants as spConsts
from scipy.integrate import quad
import numpy as np
import math
import timeit
import os
class semiconductor(object):
def __init__(self):
self.Eg=1.424 # energy bandgap of GaAs [eV]
self.mc=.0665*spConsts.m_e # electron effective mass in GaAs [kg]
self.T=300.0 # temperature [K]
self.Etol=20*spConsts.k*self.T
def concentrationE(self,Fc):
""" electron concentration"""
Fc=float(Fc) # numpy scalars are slow, avoid them like the plague. Commenting this line gives 5x speed reduction
integrand=lambda E:self.DOS(E,self.mc)*self.fermi(self.Eg+E,Fc)
integral,err=quad(integrand,0,Fc-self.Eg+self.Etol)
N=integral*spConsts.e
def DOS(self,E,m):
""" Density of states in bulk"""
rho0=1.0/2/np.pi**2*(2*m/spConsts.hbar**2)**1.5
try:
# assume E is scalar
rho=rho0*math.sqrt(spConsts.e*E)
except ValueError:
# assume E<0
rho=0.0
except TypeError:
# assume E is numpy.ndarray
rho=rho0*np.sqrt(spConsts.e*E*(E>0))
return rho
def fermi(self,E,F):
""" Fermi distribution given energy and fermi level [eV] and temperature [K]"""
try:
# Assume E and F are both scalars... math.exp(x) is 5x faster than numpy.exp(x) if x is a scalar
f=1.0/(1.0+math.exp((E-F)*spConsts.e/spConsts.k/self.T))
except TypeError:
# Assume E and F are numpy arrays
f=1.0/(1+np.exp((E-F)*spConsts.e/spConsts.k/self.T))
f[self.T==0 and E==F]=1
except OverflowError:
# If overflow error then set exponential to inf
f=0.0
except ZeroDivisionError:
f=1 if E<=F else 0
return f
if __name__=="__main__":
currModule=os.path.split(os.path.splitext(__file__)[0])[-1]
setup='from %s import semiconductor; obj=semiconductor(); import numpy; Fc=numpy.array([1.5])'%currModule
n=5
m=1000
t0=min(timeit.Timer('obj.concentrationE(Fc)',setup=setup).repeat(n, m))/m
print 'concentrationE took ' + str(t0*1000) + ' ms'
ans=raw_input("Press any key to continue...")
sys.settrace
Are you sure you want to delete this post? You will not be able to recover it later.
Are you sure you want to delete this thread? You will not be able to recover it later.