[Numpy-discussion] Re: Profiling problem

Arnd Baecker arnd.baecker at web.de
Fri May 5 12:17:02 EDT 2006


On Fri, 5 May 2006, Robert Kern wrote:

> Ryan Krauss wrote:
>
> > What does that mean?  It looks to me like 0.12 total seconds were
> > spent calling abs (with no mention of what command is calling abs),
> > and the rest of the 1.05 total seconds is unaccounted for.  Am I
> > misunderstanding this or doing something else wrong?
>
> Donuts get you dollars that the profiler does not recognize ufuncs as functions
> that it ought to be profiling.

So does that mean that something has to be done to the ufuncs
so that the profiler can recognize them, or that
the profiler has to be improved in some way?

Just for completeness: I installed python 2.5 to test out the new cProfile
which gives for
################################
import cProfile

from numpy import *
from math import sqrt

def main():
   x=arange(1,100.0)
   for i in xrange(10000):
       y=sin(x)
       y2=log(x)
       z=sqrt(i)
       z2=abs(y**3)

cProfile.run("main()")

################################

the following result:
         20004 function calls in 0.611 CPU seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.611    0.611 <string>:1(<module>)
        1    0.515    0.515    0.611    0.611 tst_prof.py:7(main)
    10000    0.081    0.000    0.081    0.000 {abs}
    10000    0.016    0.000    0.016    0.000 {math.sqrt}
        1    0.000    0.000    0.000    0.000 {method 'disable' of
                                               '_lsprof.Profiler' objects}
        1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.arange}

Best, Arnd




More information about the NumPy-Discussion mailing list