David Cournapeau wrote:
> But the show case is more interesting:
>
>  ncalls  tottime  percall  cumtime  percall filename:lineno(function)
>       1    0.002    0.002    3.886    3.886 
> slowmatplotlib.py:177(bench_imshow_show)
>       1    0.000    0.000    3.884    3.884 
> slowmatplotlib.py:163(bench_imshow)
>       1    0.698    0.698    3.003    3.003 
> /home/david/local/lib/python2.4/site-packages/matplotlib/backends/backend_gtk.py:70(show)
>  
>
>       2    0.000    0.000    2.266    1.133 
> /home/david/local/lib/python2.4/site-packages/matplotlib/backends/backend_gtk.py:275(expose_event)
>  
>
>       1    0.009    0.009    2.266    2.266 
> /home/david/local/lib/python2.4/site-packages/matplotlib/backends/backend_gtkagg.py:71(_render_figure)
>  
>
>       1    0.000    0.000    2.256    2.256 
> /home/david/local/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py:385(draw)
>  
>
>       1    0.000    0.000    2.253    2.253 
> /home/david/local/lib/python2.4/site-packages/matplotlib/figure.py:510(draw) 
>
>       1    0.000    0.000    2.251    2.251 
> /home/david/local/lib/python2.4/site-packages/matplotlib/axes.py:994(draw) 
>
>       1    0.005    0.005    1.951    1.951 
> /home/david/local/lib/python2.4/site-packages/matplotlib/image.py:173(draw) 
>
>       1    0.096    0.096    1.946    1.946 
> /home/david/local/lib/python2.4/site-packages/matplotlib/image.py:109(make_image)
>  
>
>       1    0.002    0.002    1.850    1.850 
> /home/david/local/lib/python2.4/site-packages/matplotlib/cm.py:50(to_rgba) 
>
>       1    0.001    0.001    0.949    0.949 
> /home/david/local/lib/python2.4/site-packages/matplotlib/colors.py:735(__call__)
>  
>
>       1    0.097    0.097    0.899    0.899 
> /home/david/local/lib/python2.4/site-packages/matplotlib/colors.py:568(__call__)
>  
>
>     325    0.050    0.000    0.671    0.002 
> /home/david/local/lib/python2.4/site-packages/numpy/core/ma.py:533(__init__) 
>
>       1    0.600    0.600    0.600    0.600 
> /home/david/local/lib/python2.4/site-packages/numpy/core/fromnumeric.py:282(resize)
>  
>
>       1    0.000    0.000    0.596    0.596 
> /home/david/local/lib/python2.4/site-packages/matplotlib/pylab.py:1894(imshow)
>  
>
>      10    0.570    0.057    0.570    0.057 
> /home/david/local/lib/python2.4/site-packages/numpy/oldnumeric/functions.py:117(where)
>  
>
>       3    0.000    0.000    0.513    0.171 
> /home/david/local/lib/python2.4/site-packages/matplotlib/pylab.py:883(gca) 
>
>       1    0.000    0.000    0.513    0.513 
> /home/david/local/lib/python2.4/site-packages/matplotlib/pylab.py:950(ishold) 
>
>       4    0.000    0.000    0.408    0.102 
> /home/david/local/lib/python2.4/site-packages/matplotlib/pylab.py:903(gcf) 
>
>
> For more details, see the .kc files which are the in the tbz2 archive, 
> with the script for generating profiles for kcachegrind,
Here is some stuff I tried:

   - first, we can see that in expose_event (one is expensive, the other 
negligeable, from my understanding), two calls are pretty expensive:
the __call__  at line 735 (for normalize functor) and one for __call__ 
at line 568 (for colormap functor).
   - for normalize functor, one line is expensive:  val = 
ma.array(clip(val.filled(vmax), vmin, vmax), mask=mask). If I put a test 
on mask when mask is None (which it is in my case), then the function 
becomes negligeable.
   - for colormap functor, the 3 where calls are expensive. I am not 
sure to understand in which case they are useful; if I understand 
correctly, one tries to avoid
values out of range (0, N), and force out of range values to be clipped. 
Isn't there an easier way than using where ?

   If I remove the where in the colormap functor, I have a 4x speed 
increase for the to_rgba function. After that, it becomes a bit more 
tricky to change things for someone like me who have no knowledge about 
matplotlib internals.

   Cheers,

   David

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to