comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Cyclic array interfaces
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Cyclic array interfaces [message #40193 is a reply to message #40189] Tue, 13 July 2004 15:29 Go to previous messageGo to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
Cedric wrote:
> Furthermore, consider the next example:
>
> a = fltarr(5)
> ; Option 1: Create a new array
> a = [3, 4, 5, 6, 7]
> ; Option 2: Rewrite the array
> a[0] = [3, 4, 5, 6, 7]
>
> Option 1 and 2 are equivalent, code-wise, but I would argue (and of
> course, profile, were I not lazy) that option 2 is faster, because it
> doesn't have to deallocate the array that was already contained in a,
> and allocate a new one. Of course, there are many other optimizations
> that IDL could do that would make 1 faster than 2, but considering
> RSI's approach to compile-time optimizations, I'm confident in my
> analysis.

Analysis be dammed, I counted them! And got a result that disagrees with
your analysis:

IDL> n = 10000000 & a = fltarr(n) & t0 = systime(1) & a = findgen(n) &
t1 = systime(1) & a[0] = findgen(n) & t2 = systime(1) & print, t1-t0, t2-t1
0.14000010 0.25000000
IDL> print, !version
{ x86 Win32 Windows Microsoft Windows 6.0 Jun 27 2003 32 64}

--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Collection of different size arrays?
Next Topic: IDL FFT Source Code

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 14:13:46 PDT 2025

Total time taken to generate the page: 1.11891 seconds