Changeset 2548 for trunk/testDeriv.py
- Timestamp:
- Nov 25, 2016 12:44:43 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/testDeriv.py
r2539 r2548 23 23 import time 24 24 import cPickle 25 import cProfile,pstats,StringIO 25 26 import wx 26 27 import numpy as np … … 156 157 def test1(): 157 158 fplot = self.plotNB.add('function test').gca() 159 pr = cProfile.Profile() 160 pr.enable() 158 161 M = G2stMth.errRefine(self.values,self.HistoPhases, 159 162 self.parmDict,self.varylist,self.calcControls, 160 163 self.pawleyLookup,None) 164 pr.disable() 165 s = StringIO.StringIO() 166 sortby = 'tottime' 167 ps = pstats.Stats(pr, stream=s).strip_dirs().sort_stats(sortby) 168 print 'Profiler of function calculation; top 50% of routines:' 169 ps.print_stats("GSASII",.5) 170 print s.getvalue() 161 171 fplot.plot(M,'r',label='M') 162 172 fplot.legend(loc='best') 163 173 164 def test2(name,delt ):174 def test2(name,delt,doProfile): 165 175 Title = 'derivatives test for '+name 166 176 varyList = self.varylist+self.depVarList 167 177 hplot = self.plotNB.add(Title).gca() 178 if doProfile: 179 pr = cProfile.Profile() 180 pr.enable() 168 181 dMdV = G2stMth.dervRefine(self.values,self.HistoPhases,self.parmDict, 169 182 varyList,self.calcControls,self.pawleyLookup,None) 183 if doProfile: 184 pr.disable() 185 s = StringIO.StringIO() 186 sortby = 'tottime' 187 ps = pstats.Stats(pr, stream=s).strip_dirs().sort_stats(sortby) 188 ps.print_stats("GSASII",.5) 189 print 'Profiler of '+name+' derivative calculation; top 50% of routines:' 190 print s.getvalue() 170 191 M2 = dMdV[varyList.index(name)] 171 192 hplot.plot(M2,'b',label='analytic deriv') … … 200 221 while self.plotNB.nb.GetPageCount(): 201 222 self.plotNB.nb.DeletePage(0) 223 202 224 test1() 225 226 doProfile = True 203 227 for use,name,delt in zip(self.use,self.varylist+self.depVarList,self.delt): 204 228 if use: 205 test2(name,delt) 229 test2(name,delt,doProfile) 230 doProfile = False 206 231 207 232 self.plotNB.Show()
Note: See TracChangeset
for help on using the changeset viewer.