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

Home » Public Forums » archive » Array-making speed
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Array-making speed [message #23044] Fri, 29 December 2000 10:55
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Hello,

A (long) while back there was a discussion regarding which, of a number
of methods, was most efficient at making a blank array. I couldn't
locate the archive at DejaNews, so I tried to figure out which one to
use by trial and error.

Below is the code I used to make an 640x480 zero-valued array with
MAKE_ARRAY, INTARR and REPLICATE. I tried each in a loop, with the loop
incrementing to 1, 10, 100 and finally 1000 times. The results are
shown below; note how INTARR looks non-linear when the in the 100 count
loop (I expected something between 0.16 and 0.17) . Loopy, huh? Just
gee-whiz enough that I thought I'd share it.


IDL> arraymaking
** Structure !VERSION, 7 tags, length=44:
ARCH STRING 'PowerMac'
OS STRING 'MacOS'
OS_FAMILY STRING 'MacOS'
RELEASE STRING '5.4'
BUILD_DATE STRING 'Nov 1 2000'
MEMORY_BITS INT 32
FILE_OFFSET_BITS
INT = 32
MakeArray x 1 0.0022699833
IntArr x 1 0.0016069412
Replicate x 1 0.0025990009

MakeArray x 10 0.023674965
IntArr x 10 0.016358972
Replicate x 10 0.023769975

MakeArray x 100 0.23571503
IntArr x 100 0.30677903
Replicate x 100 0.25714195

MakeArray x 1000 2.3778840
IntArr x 1000 1.7446461
Replicate x 1000 2.3371190


;---------------- START
PRO ArrayMaking

nx = 640
ny = 480

n = [1,10,100,1000]

Help, !Version, /str

For j = 0, 3 Do Begin

Start = SYSTIME(/Sec)
For i = 0, n[j]-1 Do D = MAKE_ARRAY(nx,ny,Value = 0)
Print, 'MakeArray x ',StrTrim(n[j],2), SYSTIME(/Sec)-Start

Start = SYSTIME(/Sec)
For i = 0, n[j]-1 Do D = IntArr(nx,ny)
Print, 'IntArr x ',StrTrim(n[j],2), SYSTIME(/Sec)-Start


Start = SYSTIME(/Sec)
For i = 0, n[j]-1 Do D = Replicate(0,nx,ny)
Print, 'Replicate x ',StrTrim(n[j],2), SYSTIME(/Sec)-Start

Print, ' '
EndFor ;j loop

END
;----------------END





Ben

--
Ben Tupper
Bigelow Laboratory for Ocean Sciences
180 McKown Point Rd.
W. Boothbay Harbor, ME 04575
btupper@bigelow.org
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: widget_control and group_leader
Next Topic: LABEL_REGION

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

Current Time: Wed Oct 08 14:01:15 PDT 2025

Total time taken to generate the page: 0.00495 seconds