David Cournapeau wrote:
> Eric Firing wrote:
>> There is a clip function in all three numeric packages, so a native 
>> clip is being used.
>>
>> If numpy.clip is actually slower than your version, that sounds like a 
>> problem with the implementation in numpy.  By all logic a single clip 
>> function should either be the same (if it is implemented like yours) 
>> or faster (if it is a single loop in C-code, as I would expect).  This 
>> warrants a little more investigation before changing the mpl code.  
>> The best thing would be if you could make a simple standalone numpy 
>> test case profiling both versions and post the results as a question 
>> to the numpy-discussion list.  Many such questions in the past have 
>> resulted in big speedups in numpy.
> I am much more familiar with internal numpy code than matplotlib's, so 
> this is much easier for me, too :)
>> One more thought: it is possible that the difference is because myclip 
>> operates on the array in place while clip generates a new array.  If 
>> this is the cause of the difference then changing your last line to 
>> "return a.copy()"  probably would slow it down to the numpy clip speed 
>> or slower.
> It would be scary if a copy of a 8008x256 array of double took 100 ms... 
> Fortunately, it does not, this does not seem to be the problem.
>
> cheers,
>
> David
Ok, so now, with my clip function, still for a 8000x256 double array: we 
have show() after imshow which takes around 760 ms. 3/5 are in 
make_image, 2/5 in the function blop, which is just an alias I put to 
measure the difference between axes.py:1043(draw) and image.py:173(draw) 
in the function Axis.draw (file axes.py):

 def blop(dsu):
     for zorder, i, a in dsu:
          a.draw(renderer)

 blop(dsu)

In make_image, most of the time is taken into to_rgba: almost half of it 
is taken in by the take call in the Colormap.__call__. Almost 200 ms to 
get colors from the indexes seems quite a lot (this means 280 cycles / 
pixel on average !). I can reproduce this number by using a small numpy 
test.

On my laptop (pentium M, 1.2 Ghz), make_image takes almost 85 % of the 
time, which seems to imply that this is where one should focus if one 
wants to improve the speed,

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