title: profiling numpy with cProfile not giving useful results
body: <p>This code:</p>
  
  <pre><code>import numpy as np
  import cProfile
  
  shp = (1000,1000)
  a = np.ones(shp)
  o = np.zeros(shp)
  
  def main():
      np.divide(a,1,o)
      for i in xrange(20):
          np.multiply(a,2,o)
          np.add(a,1,o)
  
  cProfile.run('main()')
  </code></pre>
  
  <p>prints only:</p>
  
  <pre><code>         3 function calls in 0.269 seconds
  
     Ordered by: standard name
  
     ncalls  tottime  percall  cumtime  percall filename:lineno(function)
          1    0.000    0.000    0.269    0.269 &lt;string&gt;:1(&lt;module&gt;)
          1    0.269    0.269    0.269    0.269 testprof.py:8(main)
          1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Prof
  iler' objects}
  </code></pre>
  
  <p>Can I get cProfile to work with numpy to tell me how many calls it makes to the varous <code>np.*</code> calls and how much time it spends on each?</p>
  
  <p><strong>edit</strong></p>
  
  <p>It is too cumbersome to wrap each of the numpy functions individually as hpaulj suggests, so I'm trying something like this to temporarily wrap many or all of the functions of interest:</p>
  
  <pre><code>def wrapper(f, fn):
      def ff(*args, **kwargs):
          return f(*args, **kwargs)
      ff.__name__ = fn
      ff.func_name = fn
      return ff
  
  for fn in 'divide add multiply'.split():
      f = getattr(np, fn)
      setattr(np, fn, wrapper(f, fn))
  </code></pre>
  
  <p>but cProfile still refers to <em>all</em> them as <code>ff</code></p>