[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: indexing expression performance
From: |
Jaroslav Hajek |
Subject: |
Re: indexing expression performance |
Date: |
Thu, 15 Jan 2009 08:11:50 +0100 |
On Wed, Jan 14, 2009 at 5:36 PM, Francesco Potortì <address@hidden> wrote:
>>Also, Francesco, I forgot to do the obvious thing and test your examples
>>with 3.1.51. At least on my machine, it looks like the performance has been
>>reversed by the latest dense indexing improvements.
>>
>>octave:1> kk=rand(156,222,1,44,8);
>>octave:2> t=cputime; for ii=1:44, for jj=1:8, mm=kk(:,:,:,ii,jj); endfor,
>>endfor, cputime-t
>>ans = 0.072004
>>octave:3> cp=[1,cumprod(size(kk)(1:end-1))]; len=156*222; t=cputime; for
>>ii=1:44, for jj=1:8,base=sum(([1,1,1,ii,jj]-1).*cp); mm=kk(base+1:base+len);
>>endfor, endfor, cputime-t
>>ans = 0.12401
>
> Wonderful! This will make my code more readable as soon as I upgrade :)
>
> Thank you Jaroslav!
>
You're welcome. After all, your original report has been the starting
impulse for that work, so part of the credit goes to you... it's hard
to work on performance improvements without such rational starting
impulses (by rational I mean not the sort of "hey guys, Octave sucks,
'cause my code is slow on it, do something 'bout it"), because there's
an awful lot of places in Octave that are amenable to some
optimizations, but of course not everything is equally painful. So,
working simplistic benchmarks that grasp the core of some performance
problem are precious stuff.
Of course, they're best done with development sources, but you know that :)
You may also be interested in the most recent indexing improvements:
http://hg.savannah.gnu.org/hgweb/octave/rev/ad3afaaa19c1
http://www.nabble.com/lazy-contiguous-subrange-indexing-td21458811.html
this will cheat your first loop to run in almost zero time...
cheers
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
- indexing expression performance, Nicholas Tung, 2009/01/13
- Re: indexing expression performance, Jaroslav Hajek, 2009/01/13
- Re: indexing expression performance, Francesco Potortì, 2009/01/13
- Re: indexing expression performance, Francesco Potortì, 2009/01/15
- Re: indexing expression performance, Jaroslav Hajek, 2009/01/15
- Re: indexing expression performance, Thomas Weber, 2009/01/16
- Re: indexing expression performance, Jaroslav Hajek, 2009/01/16
- Re: indexing expression performance, Thomas Weber, 2009/01/16
- Re: indexing expression performance, Jaroslav Hajek, 2009/01/16
- Re: indexing expression performance, Jaroslav Hajek, 2009/01/16
- Re: indexing expression performance, Jordi Gutiérrez Hermoso, 2009/01/16
- Re: indexing expression performance, Jaroslav Hajek, 2009/01/16