LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DiscardCtrl slow as molasses

Hello all,

In the past I had problems with the profiler. Since it now works in CVI2013 (thanks for fixing it), I'm using it to check out a program that takes forever to initialize. It draws some arrows into a temporary canvas and then copies them into a picture ring.

 

The drawing is slow, but I guess that's to be expected (yeah, CanvasStartBatchDraw, etc), but what I find surprising is that DiscardCtrl on said  canvas takes forever: it's called 90 times and takes 17 seconds total. Running in debug or release mode doesn't change much (only 1s difference).

 

So, is that normal, and can I optimize it ?

Thanks.

0 Kudos
Message 1 of 5
(4,214 Views)

Can you trying hiding it first, then discard?

 

This trick works for graphs. Maybe holds for canvasses too.

You can also try the same trick for drawing updates. Hide-paint-unhide.

 

Hope this helps...

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 5
(4,209 Views)

I don't even need to display it at all since it's during the creation of the panel. So the panel is not yet displayed and I set the canvas as non visible right after it's created with NewCtrl. That's still 18 seconds. I should try to create and discard it only once, clearing it instead.

0 Kudos
Message 3 of 5
(4,207 Views)

Hi Guillaume,

 

No, I don't think this is normal. I tried to reproduce it, but wasn't able to. I wrote a short program that would create 90 canvases on a hidden panel, then draw a handful of random lines to each one, and finally delete all the canvases. I timed the creation, drawing and disposal independently, and all the times were pretty short (~50 miliseconds for creation, ~5 miliseconds for drawing and ~1 milisecond for disposal, for all 90 canvases).

 

There must be some other factor that is affecting your program that I'm not capturing. I'm attaching my program here. Maybe you can gradually combine yours and mine until we can isolate the factor that is making it so slow.

 

I only ran mine in Windows. Are you seeing this in Windows or Linux?

 

Luis

0 Kudos
Message 4 of 5
(4,168 Views)

Hello LuisG,

I see the problem in Windows. In Linux it's actually much faster. I now use a single Discard for the whole sequence and it's much faster, so I'm concentrating on other problems as this is minor (see my other incoming post). I'll try you prog later. Thanks.

0 Kudos
Message 5 of 5
(4,119 Views)