[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Strange memory problem
Liam Gumley <Liam.Gumley@ssec.wisc.edu> wrote in message
3860E331.C4E36EA4@ssec.wisc.edu">news:3860E331.C4E36EA4@ssec.wisc.edu...
> "Mark D. Williams" wrote:
> > FWIW, if you want to save time and memory, a faster way to do the above
> > is as follows:
> >
> > WAVE> temp = BYTARR(1000,1000,25, /NoZero) + 10B
>
> I get the fastest response (in IDL) with
>
> temp = replicate(10B, 1000, 1000, 25)
>
> Cheers,
> Liam.
OK, After I figured out to clear the memory between calls, I got the
following numbers (before clearing the temp array, the numbers just kept
growing...):
0.33000004 Seconds (temp=bytarr(1000,1000,25))
1.5920000 Seconds (replicate_inplace, temp, 10B)
2.0829999 Seconds (temp = BYTARR(1000,1000,25) + 10B)
1.9130000 Seconds (temp = BYTARR(1000,1000,25, /NoZero) + 10B)
1.5619999 Seconds (temp = replicate(10B, 1000, 1000, 25))
pro test_array_init
T = SYSTIME(1)
temp=bytarr(1000,1000,25)
PRINT, SYSTIME(1) - T, ' Seconds (temp=bytarr(1000,1000,25))'
temp = 0
; the following takes a *very* long time
;temp(*)=10B
;PRINT, SYSTIME(1) - T, ' Seconds'
T = SYSTIME(1)
temp=bytarr(1000,1000,25)
replicate_inplace, temp, 10B
PRINT, SYSTIME(1) - T, ' Seconds (replicate_inplace, temp, 10B)'
temp = 0
T = SYSTIME(1)
temp = BYTARR(1000,1000,25) + 10B
PRINT, SYSTIME(1) - T, ' Seconds (temp = BYTARR(1000,1000,25) + 10B)'
temp = 0
T = SYSTIME(1)
temp = BYTARR(1000,1000,25, /NoZero) + 10B
PRINT, SYSTIME(1) - T, ' Seconds (temp = BYTARR(1000,1000,25, /NoZero) +
10B)'
temp = 0
T = SYSTIME(1)
temp = replicate(10B, 1000, 1000, 25)
PRINT, SYSTIME(1) - T, ' Seconds (temp = replicate(10B, 1000, 1000, 25))'
temp = 0
end
Julie
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Juliet G. Greenwood
Senior Programmer
Oceanweather Inc.
JulieG@Oceanweather.com
http://www.oceanweather.com/
http://www.thehungersite.com/
The Hunger Site - Donate Food for Free to
Feed Hungry People in the World.
The Site's Sponsors Make the Donations.