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

Home » Public Forums » archive » Slowdown when creating/destroying Object Graphics components
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
Slowdown when creating/destroying Object Graphics components [message #47423] Wed, 08 February 2006 12:14
David  Watson is currently offline  David Watson
Messages: 2
Registered: June 2005
Junior Member
I'm working on a program that creates/destroys a large number of ROIs,
and noticed a slowdown after it has been running for certain amount of
time. I was able to boil it down to this simple test program, which
illustrates the problem perfectly.

On my machine, under both linux and windows, IDL 6.1 and 6.2, this
slowdown is clearly indicated - the first loop takes about 4 seconds,
gradually increasing each time through. After about 10-20 iterations,
it is taking upwards of 10 seconds per loop.

I made a few variations of this program, and was able to determine a
few things:

* The slowdown appears to be in the IDLGrWindow object. If I destroy
and recreate it, it returns to the original speed. Destroying and
recreating a view and model has no impact.
* If I reuse, and do not destroy, the IDLGrRois, the slowdown does not
occur. Removing the IDLGrRois from the IDLGRModel, and then re-adding
them has no speed impact.

Here's the code for my test:

FUNCTION getRoi, oModel, aPos, oRoi, COLOR=aColor
angles = FINDGEN(3600) / 10.0
angles = angles * !PI / 180.0
cosines = COS(angles) / 8.0 + aPos[0]
sines = SIN(angles)/8.0 + aPos[1]

aCircleData = TRANSPOSE([[sines],[cosines]])

IF OBJ_VALID(oRoi) THEN BEGIN
oModel->remove, oRoi
OBJ_DESTROY, oRoi
ENDIF
oRoi = OBJ_NEW('IdlGrRoi', COLOR=aColor,aCircleData )
oModel->add, oRoi

return, oRoi
END

PRO testcontours
oWindow = OBJ_NEW('IDLGRWindow', TITLE='Test Window', DIM=[400,400])
oWindow->show, 1

oView = OBJ_NEW('IDLGRView')

oModel = OBJ_NEW('IDLGRModel')
oModel->scale, 2, 2, 1

oModel->translate, -1, -1, 0
oView->add, oModel

angles = FINDGEN(360)
angles = angles * !PI / 180.0
cosines = COS(angles) / 4.0 + 0.5
sines = SIN(angles)/4.0 + 0.5

aColors = [[255,0,0], [0,255,0], [0,0,255], [0,0,0]]

aROIs = OBJARR(4)

FOR i = 0, 40 DO BEGIN
starttime = systime(/seconds)
FOR j = 0, 359 DO BEGIN
FOR k = 0, 3 DO BEGIN
aOffset = [cosines[(j+90*k) MOD 360],sines[(j+90*k) MOD 360]]
aRois[k] = getRoi(oModel, aOffset, COLOR=aColors[*,k],
aRois[k])
ENDFOR
oWindow->draw, oView
ENDFOR
print, systime(/seconds)-starttime
ENDFOR

oView->remove, oModel
OBJ_DESTROY, oModel
OBJ_DESTROY, oView
OBJ_DESTROY, oWindow
END
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL VM problems
Next Topic: Calculate maximum diameter?

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

Current Time: Wed Oct 08 19:17:16 PDT 2025

Total time taken to generate the page: 0.00524 seconds