Re: Arrays suck. Loops rock. [message #42948] |
Tue, 08 March 2005 11:51  |
Y.T.
Messages: 25 Registered: December 2004
|
Junior Member |
|
|
> IDL> test_loop,findgen(300,300,10),findgen(10,20),disps,nloops=0
> took 1.1159251 sec
> IDL> test_loop,findgen(300,300,10),findgen(10,20),disps,nloops=1
> took 0.96256900 sec
> IDL> test_loop,findgen(300,300,10),findgen(10,20),disps,nloops=2
> took 2.0543392 sec
> IDL> test_loop,findgen(300,300,10),findgen(10,20),disps,nloops=4
> took 27.267108 sec
>
I'd like to add to this that I sure hope you guys didn't just run each
call once -- for then the results you get are utterly arbitrary. At the
level of a sizable fraction of a second the OS can throw stuff at you
for no better reason than that it is tuesday. On your first call, IDL
has to allocate a lot of memory, for example, which it may or may not
free up and thus it may or may not be faster on the second call. Any
memory allocation may or may not proceed swiftly depending on how much
cleanup the OS has to do before it can hand IDL the requisite amount of
memory. And so forth.
Thus for any kind of timing comparisons you'll always want to re-run
the routine in question at least a couple times (ideally something like
1000 times from a loop and then compute the average). Otherwise you're
measuring OS latency because of a big TCP packet that happened to hit
your ethernet port just that moment (or similar things) rather than the
actual speed of the algorithm.
(I honestly fail to understand the provided example and am not at all
sure that the two "rebins" are necessary. You are aware that 'rebin'
performs interpolations, right?)
cordially
Y.T.
--
Remove YourClothes before you email me.
|
|
|