help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trying to optimize my octave program


From: Judd Storrs
Subject: Re: trying to optimize my octave program
Date: Thu, 18 Mar 2010 09:41:40 -0400

What you need to try and figure out is where the time is being spent.
Vectorization can work to get things fast but at a certain point the
gains can be offset by increased and less efficient use of memory. The
more tightly packed you can get your memory the better the hardware
can work to keep data flowing through the CPU. Purging for loops isn't
always the best solution. Generally speaking, the more work that is
done with each pass through the for loop, the less the execution time
difference between for-based and vectorized code. These links concern
a different but somewhat similar language called IDL:

Are FOR Loops Evil?
http://www.dfanning.com/tips/forloops.html

Are FOR Loops Really Evil?
http://www.dfanning.com/tips/forloops2.html

Not knowing even in general what sort of problems your code is facing,
it's difficult to suggest strategies. Now going out into wild
speculation land what I understand is that

* Your code takes over one day to complete
* Your code spends that time in a loop that takes possibly less than 0.01 sec

This implies that your loop is executed at least 24*60*60/0.01 =
8640000 times. If that isn't anywhere near how many times it is
executed then your cycles are being wasted elsewhere. In wild
speculation land I would say your inner loop isn't "doing enough work"
with each pass.

Again its difficult for us to guess about these things so if you can
somehow extract part of the algorithm or do some more detective work
on where the hangup is we may be able to help more specifically--as is
all you've told us is that you wish your code ran faster. Without more
hints it's hard to help you.


--judd


reply via email to

[Prev in Thread] Current Thread [Next in Thread]