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 #65712 is a reply to message #65624] Mon, 16 March 2009 03:39 Go to previous message
oxfordenergyservices is currently offline  oxfordenergyservices
Messages: 56
Registered: January 2009
Member
On 14 Mar, 22:28, Michael Galloy <mgal...@gmail.com> wrote:
> oxfordenergyservi...@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

0k, thanks Mike, that makes sense!
[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: Sat Oct 11 13:43:20 PDT 2025

Total time taken to generate the page: 0.21539 seconds