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

Home » Public Forums » archive » Re: idl speed question
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: idl speed question [message #65624] Sat, 14 March 2009 15:28 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
oxfordenergyservices@googlemail.com wrote:
> I have the following strange result
>
> a=double(1.0)
> for i=0,10000 do begin
> for j=0,10000 do begin
> a=a+1.0
> endfor
> endfor
>
> takes 13 seconds whereas
>
> a=double(1.0)
> b=double(1.0)
> c=double(1.0)
> d=double(1.0)
> e=double(1.0)
> for i=0,10000 do begin
> for j=0,10000 do begin
> a=a+1.0
> b=b+1.0
> c=c+1.0
> d=d+1.0
> e=e+1.0
> endfor
> endfor
>
> takes 60 seconds? I thought the overhead with IDL was in the loops
> rather than the computing?

The real killer for speed is number of statements (each one has to be be
interpreted). Loops are bad only because they could execute a statement
a possibly large number of times. So in your example, the first case has
10001 * 10001 statements while the second has 5 * 10001 * 10001
statements. So if the statements are doing the same amount of work, one
would expect the second to take about 5 times more time.

The conclusion: try to do more work per statement.

Mike
--
www.michaelgalloy.com
Associate Research Scientist
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Previous Topic: Re: IDL on linux "out of the box", license
Next Topic: Running bucles on LINUX terminal

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

Current Time: Fri Oct 10 13:18:15 PDT 2025

Total time taken to generate the page: 0.06561 seconds