python-version 3.6.8
Like we discussed in office hour today, I wrote cProfile to get the time it takes to run function call and it's good.
original code:
#start the cProfile timer here
prof.enable()
ret = benchmarkFunction(x,lambda x: 2*x,timestep) #function that does the calculation
prof.disable()
s = io.StringIO()
sortby = 'time'
ps = pstats.Stats(prof, stream=s).sort_stats(sortby)
ps.print_stats(10)
print(s.getvalue())
I got Output like below:
14809 function calls in 0.054 seconds
Ordered by: internal time
List reduced from 64 to 10 due to restriction <10>
ncalls tottime percall cumtime percall filename:lineno(function)
21 0.018 0.001 0.054 0.003 <ipython-input-101-80a6d7e4cb13>:3(benchmarkFunction)
171 0.008 0.000 0.008 0.000 {built-in method posix.urandom}
171 0.005 0.000 0.013 0.000 /anaconda/lib/python3.6/site-packages/ipykernel/iostream.py:180(schedule)
126 0.005 0.000 0.012 0.000 /anaconda/lib/python3.6/site-packages/numpy/core/arrayprint.py:557(fillFormat)
3008 0.002 0.000 0.002 0.000 <ipython-input-142-6dfb0bcdc2b9>:19(<lambda>)
378 0.002 0.000 0.002 0.000 {method 'reduce' of 'numpy.ufunc' objects}
168 0.001 0.000 0.015 0.000 /anaconda/lib/python3.6/site-packages/ipykernel/iostream.py:342(write)
336 0.001 0.000 0.002 0.000 /anaconda/lib/python3.6/site-packages/numpy/core/numeric.py:2692(seterr)
126 0.001 0.000 0.001 0.000 {method 'compress' of 'numpy.ndarray' objects}
336 0.001 0.000 0.001 0.000 /anaconda/lib/python3.6/site-packages/numpy/core/numeric.py:2792(geterr)
python-version 3.6.8 Like we discussed in office hour today, I wrote cProfile to get the time it takes to run function call and it's good. original code:
I got Output like below:
And I need to get the tottime from this line:
How can I do that?